Hi everyone,
I'm not sure if I'm doing something wrong or if this is how it's supposed to be.
I was experimenting loading a big image, and then loading a different one into the same variable. I expected that the memory stayed about the same, but it increased. If i repeat the process, even with the same image, the memory goes on increasing forever.
I made this short piece of code to illustrate this: http://hastebin.com/yororoxoyu.lua
Even by setting the var to nil, the memory doesn't get lower.
If I keep repeating it, eventually the game and love crash when the memory usage reaches 100%.
In this example I used ImageData just to make sure the problem wasn't only with newImage itself.
tips?
thanks
Memory is not getting free'd
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: Memory is not getting free'd
This might sound stupid but...
Did you tried using collect garbage function ? Here's how to use it.
Did you tried using collect garbage function ? Here's how to use it.
- bartbes
- Sex machine
- Posts: 4946
- Joined: Fri Aug 29, 2008 10:35 am
- Location: The Netherlands
- Contact:
Re: Memory is not getting free'd
Adding collectgarbage solves this for me. The reason is that lua doesn't realize your images are this large, and it's not in a hurry to clean up all those tiny values.
Re: Memory is not getting free'd
Does it perhaps cache and reuse the images? Or in other words, if you alternate between loading two images, does the memory usage still go up or does it stop after they've both been loaded once?
My game called Hat Cat and the Obvious Crimes Against the Fundamental Laws of Physics is out now!
Who is online
Users browsing this forum: Ahrefs [Bot], Bing [Bot], Google [Bot] and 5 guests