I have been here for memory leak problems before… And it is boring me… I have been developing games on Corona for more than 1 year and I couldn’t release any of those games because of unsolved problems with memory leak.
Perhaps Brent Sorrentino still reminds once I’ve been here searching for help to correctly remove the objects of my apps and, even with the help of many people, I could find the answer for my problems…
And here I am again in search of that answer to solve my memory leak problems.
I use the for loop below within a Runtime-enterFrame function called “detectOffscreenItems” and it runs while the game is not over. The problem is that I keep on creating the smallObjects and even with the remover function running, the memory usage keeps going up and up. Then, when I want to restart the level, I cancel the detectOffscreenItems function and use a function alike the one below to clean what remains of the smallObjects. When the scene I was comes up again, the memory usage is as high as when I went out of the scene, as if I had not cleaned the smallObjects…
for i = #smallObjects, 1, -1 do local oneSmallObject = smallObjects[i]; if(oneSmallObject and oneSmallObject.x)then if(oneSmallObject.x \> \_W + oneSmallObject.width)then if(oneSmallObject.trans)then transition.cancel(oneSmallObject.trans); oneSmallObject.trans = nil; end display.remove(oneSmallObject); oneSmallObject = nil; table.remove(smallObjects, i); end end end
Even in the MultiPuck Corona sample the detectOffscreenItems works badly and does not remove everything from the memory…
Can someone tell me what’s going on, please?!