Memory Management Problem

Hey Guys,
I have gotten to the testing part of my app, and I have noticed that each time I switch from a screen and back to the same screen my memory usage has increased by a byte. For example, I start on my menu screen, my memory usage at that point is 150, and then switch to my level screen and then back to the menu and the memory has increased to 151. Im using Director 1.3 and I have nilled and removed everything. Is this increase normal?

Im using this function to check my memory and texture usage.
[lua]local function memCheck (event)

collectgarbage(“collect”)

print(“System Memory : " …(collectgarbage(“count”)/1000)…” MB")

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

end

local timerCheck = timer.performWithDelay( 1000, memCheck, -1 )
[import]uid: 17138 topic_id: 12789 reply_id: 312789[/import]

I don’t know. I used the code and the memory usage increased everytime i change the scenes. Maybe it’s a bud. [import]uid: 44110 topic_id: 12789 reply_id: 84683[/import]

When you say every time, do you mean if you went screen1, screen2 10 times you’d get 10 bytes?

I wouldn’t stress on this too much, 1 byte is ridiculously small and to make an impact one would have to sit there switching back and forth between screens for many, many hours without a break, constantly.

Would still be interested in hearing the answer to the first question, though.

Peach :slight_smile: [import]uid: 52491 topic_id: 12789 reply_id: 84743[/import]

I maybe wrong but I am affraid you are looking at a 1 KB and not 1 byte. The memory code you show I think show lua memory is KB so 150 is actually 150 KB so 1KB is pretty big if it seems to increase forever when switching screens.

I will suggest looking at this link

http://developer.anscamobile.com/forum/2011/11/19/corona®-profiler-line-line-analysis-your-code-promo-codes-included-0

The memory profiler indicated there is a great tool for this kind of issues. I have used it to find many memory leaks in my code and I could not function without it now!

Good luck.

Mo [import]uid: 49236 topic_id: 12789 reply_id: 84763[/import]

Everytime. And it isnt only 1 byte, sometimes its 5-10 bytes.

I tried

[code]
local monitorMem = function()

collectgarbage()
print( "MemUsage: " … collectgarbage(“count”) )

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

Runtime:addEventListener( “enterFrame”, monitorMem )

–and
timer.performWithDelay(1, function() collectgarbage(“collect”) end)
–all didnt work [import]uid: 44110 topic_id: 12789 reply_id: 85922[/import]

I wouldn’t be too concerned about such a small amount BUT I would suggest creating a new project, very basic, then switching between scenes a few times to see if you get any spike with it. (I say a small test project because this way you can test with only one or two objects and it could help isolate things.)

Peach :slight_smile: [import]uid: 52491 topic_id: 12789 reply_id: 86038[/import]

Thanks! No more memory leaks! [import]uid: 44110 topic_id: 12789 reply_id: 86208[/import]

Well done! :slight_smile: [import]uid: 52491 topic_id: 12789 reply_id: 86276[/import]