Director 1.3 Memory "bloat"

Okay, I wouldn’t really call this a leak, because it stops at a certain point, but there’s definitely stuff not being freed in memory. For example, if at a main menu screen, my app might start with 100 memory used, going to the about page might boost this up to 120, when I return to main I’ll be at 110. Going to about and returning to main will leave this number at 110. However, now if I go to the awards page and page, my memory useage at the main menu is 120. Again, going back and forth won’t raise it anymore.

So, I’m not leaking, but by loading a scene, it seems like there’s a chunk of memory that director sets aside and then maybe re-uses later? Whatever the case may be, I have a LOT of scenes in my game, and I’ll often get to a scene after having visited 20 others and instead of my memory usage being 150, it’s like 400 because all those other scenes don’t appear to unload completely. Anyone know why this is happening or how to fix it so that director correctly unloads the entire scene? [import]uid: 75335 topic_id: 12696 reply_id: 312696[/import]

Hi wthur001,

I’ve noticed the same thing in my apps, but I don’t think it has to do with director in my case. It seemed to me that it was the libraries I was using (because director doesn’t and shouldn’t close those when leaving a page). By libraries, I mean as in this stuff.

[lua]local ui = require (“coronaui_ui”)
local easingx = require(“easing”)
require “sprite”
local loqsprite = require(“loq_sprite”)
require(“loq_profiler”).createProfiler()[/lua]

When you require a library you are including all that code into your memory one time (there’s no leaks with that stuff), but they don’t get included until you reach the page that requires it. If you want to cut down on that, you could comment out the parts of the libraries that you aren’t using, but otherwise, there’s not much you can do.

That may be what’s going on with your code, I hope that helps.

-Matt
W2MD [import]uid: 10211 topic_id: 12696 reply_id: 46515[/import]

I wish that were the case, but it’s not. It seems to bloat by the size of the file it’s loading and never goes back. It can literally be as simple as making a background with a click listener that just reloads mainmenu and it’ll bloat. Even with everything inside new, variables as local, and inserted into the localGroup. Even removing the eventlistener on click, setting both that function, and the new function to nil won’t stop the bloat.

Try it out with a mainmenu.lua that loads an image, gives it a touch listener and sends you to submenu.lua. Do an image with a touch listener in submenu.lua that sends you back to mainmenu.lua. When you return to mainmenu from submenu your memory footprint WILL be higher than the first time you hit mainmenu on it’s first load. [import]uid: 75335 topic_id: 12696 reply_id: 46526[/import]

i have noticed similar behavior and still scratching my head over what i should be freeing. is it director or is it something else.

Do you set the director group also to selfRemove and nil before you leave the scene?

regards
[import]uid: 55009 topic_id: 12696 reply_id: 46552[/import]

@wthur001, when you say 100, 200 or 110 what do you mean and how do you get that? If you are using texture memory, that has nothing to do with the memory, that is just the memory used for display objects (AFAIK).

cheers,

?:slight_smile: [import]uid: 3826 topic_id: 12696 reply_id: 46557[/import]

local counterMem = 0
local monitorMem = function()
if(counterMem == 300) then
counterMem = 0
collectgarbage()
print( "\nMemUsage: " … collectgarbage(“count”) )

local textMem = system.getInfo( “textureMemoryUsed” ) / 1000000
print( "TexMem: " … textMem )
end
counterMem = counterMem +1
end

Runtime:addEventListener( “enterFrame”, monitorMem )

That’s the code I’ve got to dumb memory usage every couple of seconds into the terminal. Texture memory ALWAYS frees properly, I never forget to put the image into the group I pass director. However, it is the collectgarbage(“count”) that bloats. I.E the executing code in memory right? That number continuing to increase is bad as I’ve been told :slight_smile: Any ideas? [import]uid: 75335 topic_id: 12696 reply_id: 46658[/import]

same for me here. would love to get to the bottom of this. [import]uid: 55009 topic_id: 12696 reply_id: 46681[/import]

In director 1.2 (and 1.3 beta) there was a clean function. Ricardo removed that from 1.3 but I think there will be a new one at the end of the month (that’s what he said) with clean function added back.

I would suggest using 1.2 for now (that’s what I’m doing now) and use clean function to clean up all sounds, timers, etc. you might have left over…simply anything not a display object added to the director group. [import]uid: 10478 topic_id: 12696 reply_id: 46696[/import]

PixelEnvision, I am using none of those things. Literally, I make a single image, give it a listener to change scenes to a sub menu and at the submenu make an image, give it a listener to return to the main menu, and the code bloats. It doesn’t *leak* as in memory increasing every time. It only does it one time. :frowning:

[import]uid: 75335 topic_id: 12696 reply_id: 46708[/import]

@wthur001

If that’s the case I wouldn’t worry about that much :slight_smile:

Also, are have nil out listeners once their job is done?

Btw, collectgarbage count is not fixed. it’ll start at some point and continue to rise till garbage collector kicks in…

Spriteloq has a very nice visualiser for that (and also the texture memory)

http://www.loqheart.com/spriteloq/download.html

Download API Library Code and put the lua files in to your project and requre loq_profiler.lua :wink: [import]uid: 10478 topic_id: 12696 reply_id: 46711[/import]