Properly dispose of ui buttons & mem usage between scenes

Hopefully this is a quick response for some of you experts, even though it’s kind of a multi-part question.

1) If I am implementing the ui.lua button (or multiple in a scene), what is the proper way to dispose of these? I am using the director class and have my own cleanup method ready to go when the scene changes. I suppose I am most concerned with how the button listener get’s disposed of.

On a related note, I am tracking memory usage from scene to scene. **Is it normal:

a) for the lua mem usage to continue to rise for some time (15-20 sec) at which point GC kicks in and lowers the memory but NOT to the original usage reported by the scene at load time?

b) as I change between two scenes, the lua memory usage change fluctuates proportionately up and down however, the base values seem to go up. It’s like each time I go into a new scene, the base memory jumps up but only the first time it’s accessed. My instinct says there isn’t a memory leak but I don’t trust my instinct 100% here.**

example:
scene 1 reports 178.3 -->
switch to scene 2 which reports 239.1 -->
return to scene 1 reports 190.5 -->
back to scene 2 reports 239.1 -->
back to scene 1 reports 190.6

in this example, if I continue to load additional scenes, it seems the base values of memory usage do go up but as I switch back and forth between them, they maintain consistent values so it seems like each scene is properly disposing of what was in it but something is hogging additional memory. Any clues as to why that is?

I appreciate any help or insight out there.

[import]uid: 15934 topic_id: 6664 reply_id: 306664[/import]

This is exactly what happens to my app, now --I’m also using Director.

I successfully fixed a memory leak by replacing movieclips with spritesheets, but now, even tho the GC count remains stable, it doesn’t get lower when I get back to previous screen. And since my app (an illustrated children book) has more than 25 screens, I’m afraid it’s gonna be a problem when reaching the end of the book --so far, the GC count is around 800 when reaching page 12.

It seems not everything is cleaned up in Director’s clean() function. I removed listeners, timers and sounds, I emptied tables, but I guess something remains.
I’m suspicious about the sound, because I tried with and without the audio.dispose() function for all the loaded sounds, and the GC afterwards (ie. on next screen) is exactly the same in both cases. I use audio.stop() before disposing of the sounds, so I don’t understand why the GC doesn’t get lower.

If an expert/Corona guy could help us here, it would really be appreciated.

Thank you.
Ch. [import]uid: 4958 topic_id: 6664 reply_id: 27767[/import]

I also just noticed this issue. I just added the following to all my level files with buttons:

if Bn1 then Bn1:removeSelf(Bn1); Bn1=nil; end if Bn2 then Bn2:removeSelf(Bn2); Bn2=nil; end

Once I did that it cut my memory jumps down by 200; but I am still concerned that it won’t be enough by the time I am finished creating all my levels.

Do we need to also do this for all the buttons:

yourButton:removeEventListener( "touch", yourButton )

Thanks for any support provided.

Rob

[import]uid: 16527 topic_id: 6664 reply_id: 39136[/import]