Memory leak prevention

I’m following instructions at ‘Memory Leak Prevention 101’ link here:
http://blog.anscamobile.com/2011/08/corona-sdk-memory-leak-prevention-101/

I followed every step but testing my app it seems that every page I go to, increases the memory usage a bit more.

To understand what is consuming memory I tried with a very simple project, two pages with very simple graphics and only page swipes, no buttons; when I simulate it (printing mem and textmem usage ) when I go to the second page and the go back to the first, the memory usage raises a bit. Anyone can suggest me how I can avoid this or what could cause the memory consumption ?

Here is the link to the project: http://dl.dropbox.com/u/10259282/leaktest.zip

Thank you

Ray
[import]uid: 106680 topic_id: 19725 reply_id: 319725[/import]

I 'm struggling the same with memory leaks, I can’t really help you but maybe give the following advice :
Try Corona Profiler to narrow your mem leak issue to some lines or a function, then if you don’t find, submit to the forum (I’m just about to do the same:) [import]uid: 9328 topic_id: 19725 reply_id: 76399[/import]

In a quick look at the code I didn’t see anything that should be leaking. It could be Director leaking.

How much are we talking?

Have you run it against instruments? (If you’re on iOS) to make sure its not a natural increase in memory and not a leak?
One other note the texturmem / 1000000 should be texturemem / 1048576 if you want it in real megabytes. Since you’re looking for a relative increase it really doesn’t matter, but if you want to know exact megabytes, there is a huge difference between 1,000,000 and 1,048,576.
[import]uid: 19626 topic_id: 19725 reply_id: 76418[/import]

We did a memory profile on the code you provided you can view the results here:

http://www.mydevelopersgames.com/site/Profiler/LeakTest/profileTimeline.html

We do not see any memory leaks. You do get intermittent allocations when you switch scenes but deallocations match these exactly so you get no net memory increase.

check out our blog for instructions and for a memory leak tips
http://www.mydevelopersgames.com/site/corona-profiler-5/corona-profiler-case-study/

Thanks,
M.Y. Developers [import]uid: 55057 topic_id: 19725 reply_id: 76429[/import]

Thanks to everybody, from what I see (using the print mem and textmem code) in this test the memory leak is very very low because it’s a very simple project, but on the complete app it’s much more, I’m going to use Profiler to diagnose problems, thanks Antheor I didn’t know Profiler :slight_smile:

M.Y.developers, thank you, I just wrote to your email because I’m going to purchase Profiler but I need just an information

Ray

[import]uid: 106680 topic_id: 19725 reply_id: 76432[/import]

Looking at the Graph from M.Y. Developer’s profile of the app, its not leaking memory.

The initial ramp up is expected as all memory is being allocated, but the graph flat lines after that and doesn’t continue to grow.

[import]uid: 19626 topic_id: 19725 reply_id: 76433[/import]

Thanks everybody for your help here. I am trying to clean up every thing into Kwik (BitLuna is using my plugin) and I just purchased Corona Profiler to help even more (at this moment I am learning how to use it (find and fix issues).

Fortunately it seems I have done a decent job at this moment :slight_smile:
Alex [import]uid: 4883 topic_id: 19725 reply_id: 76450[/import]

Hey guys,

I also would like to say thank you for all the GREAT info about memmory.

BTW @M.Y.developers , how would you be able to get that nice graph done and even when passing the mouse over it show the exactly line of the code that was working during the timeline?
Happy New Year Friends 2012!

Cheers,
Rodrigo. [import]uid: 89165 topic_id: 19725 reply_id: 76454[/import]

@Rodrigo,
The graph was generated using our third party tool Corona Profiler. You can find more information about it at our website/blog here:
http://www.mydevelopersgames.com/site/

If you are interested we can put up a similar profile for your own code for you to look at. Just put up a zip file with your code snippet and we will take a look at it.

Thanks,
M.Y. Developers [import]uid: 55057 topic_id: 19725 reply_id: 76466[/import]

Alex I’m starting using Corona profiler on my app and it seems ‘director’ is responsible for most of the memory leaks [import]uid: 106680 topic_id: 19725 reply_id: 76477[/import]

Glad I helped you to discover Profiler:)
Leaking is so frustrating… [import]uid: 9328 topic_id: 19725 reply_id: 76512[/import]

@M.Y.developers,

Thank you for the quick reply and even the free offer of analysing any code of mine.

BTW Ive got impressed with the analytics graphs made by the Corona Profiler and the "looks" that its easy to get working that I`ve bought a copy of your Profiler. :slight_smile:

Just did the download and will start seeing it soon as that now it`s very late here.
Thank you one more time.
Rodrigo. [import]uid: 89165 topic_id: 19725 reply_id: 76536[/import]