Memory is not getting free'd

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
nuno
Party member
Posts: 137
Joined: Wed Dec 11, 2013 12:00 pm
Location: Portugal
Contact:

Memory is not getting free'd

Post by nuno »

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
_Yank
Prole
Posts: 8
Joined: Thu Feb 20, 2014 8:34 pm

Re: Memory is not getting free'd

Post by _Yank »

This might sound stupid but...
Did you tried using collect garbage function ? Here's how to use it.
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Memory is not getting free'd

Post by bartbes »

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.
User avatar
T-Bone
Inner party member
Posts: 1492
Joined: Thu Jun 09, 2011 9:03 am

Re: Memory is not getting free'd

Post by T-Bone »

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?
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot], Google [Bot] and 5 guests