Help with removing objects and garbage collection

Hi,
I have another memory leak in my app - fairly large one (so i hope obvious!)

I am struggling to remove objects / groups.

Does anyone have any examples of how it should be done?

At present i use the following but it seems to have no effect (i quit the level and the memusage does not drop. It does not rise if i reload the level).

if levelGroup then
–levelGroup:removeSelf()
display.remove( levelGroup )
levelGroup = nil
end

I hope someone can help me in this area.

Thank you

[import]uid: 125592 topic_id: 26738 reply_id: 326738[/import]

First, is levelGroup a member of another group?
If so,

levelGroup:removeSelf()
is better than
display.remove( levelGroup )
Second, memory is not freed immediately.

Try adding this after it (while testing only!)

collectgarbage() [import]uid: 108660 topic_id: 26738 reply_id: 108432[/import]

Thanks for the reply, i’ve tried both your suggestions but nothing is working.

The Texture Memory is fine, sir’s my lua Mem Usage thats high,

Whilst it’s good to know that it’s high - i don’t know what elements cause this? Do you have any suggestions as to what causes this to rise?

It is simply not dropping correctly between new scenes.

HELP! [import]uid: 125592 topic_id: 26738 reply_id: 108438[/import]

What is your mem usage?

It is okay if it stays the same between scenes. The problem is if it continues to go up and up betweens scenes. Is that the case? [import]uid: 75779 topic_id: 26738 reply_id: 108480[/import]

It’s high in my levels, 600, but before it loads the level it is at 240, I quit the level and expect it to go back to 240, it doesn’t!

If I reload that level it’s back to 600, but if I load a new level I’m up past 900, this is the same for each new level.

Any common pitfalls that I’m likely to have made? [import]uid: 125592 topic_id: 26738 reply_id: 108527[/import]

Something is not getting removed. Have you tried removing(and setting to nil) all the display objects instead of just the group?

Also what are you using for scene changes? Storyboard is good at cleaning up memory between scenes. [import]uid: 75779 topic_id: 26738 reply_id: 108543[/import]

Something is not getting removed. Have you tried removing(and setting to nil) all the display objects instead of just the group?

Also what are you using for scene changes? Storyboard is good at cleaning up memory between scenes. [import]uid: 75779 topic_id: 26738 reply_id: 108544[/import]

Thanks rmckee

I’m using director, is it more likely that it’s display objects or timers that are stuck. Excuse my ignorance, but does the MemUsage refer to lines of code and Texmem graphics?

I’ll take the time to,or row to sift through everything and see what the state of it is, should I place my clean functions by my changescene command, or I’m a general function?

Thanks [import]uid: 125592 topic_id: 26738 reply_id: 108547[/import]

Sounds like you have a big leak, see this guide: http://developer.anscamobile.com/forum/2012/05/21/guide-findingsolving-memory-leaks [import]uid: 84637 topic_id: 26738 reply_id: 108685[/import]