I have faced the same issues regarding the memory management.
Corona tell us that is you use Composer library , it will automatically handle memory & objects , But is Doesn't.
Try to remove each of your scene object Manually in Hide() phase & set that group reference to nil.
You can use the following code block to refer the memory leakage in you app/game.
Memory Leak:
It is the concept of constantly increasing memory use because of unnecessary allocation of memory. Leak is said to occur as soon as memory in device is exhausted, any attempt to allocate more memory causes application to terminate itself or it will negatively affect the performance.
In corona following function can be use to check the memory allocation:
local function printMemUsage()
local memUsed = (collectgarbage("count"))/1000
local texUsed = system.getInfo("textureMemoryUsed")/1000000
print("\n---------MEMORY USAGE INFORMATION---------")
print("System Memory Used:", string.format("%.03f", memUsed), "Mb")
print("Texture Memory Used:", string.format("%.03f", texUsed), "Mb")
print("------------------------------------------\n")
return true
end
Runtime:addEventListener("enterFrame", function() collectgarbage("step") end)
timer.performWithDelay(2000, printMemUsage, -1)
There is a limit on the maximum texture size that a device will support. If you exceed this limit, the texture will automatically downscale to fit within the maximum. You can use the system.getInfo( "maxTextureSize" ) command to determine the maximum texture size for a particular device. See system.getInfo() for more information.
Memory Leak Prevention:
Avoid overloading the memory :
Avoid loading too many images into one lua scene.
Handling the globals:
Don’t forget to unload the global variables. Mostly use local variable.
Free up memory :
Before switching to another scene remove all unnecessary timers, transitions runtime event listeners, display objects.
Use the following method to free the memory-
timer.cancel( timer_name ); timer_name = nil -- to remove timers
transition.cancel( tran_name ); tran_name = nil -- to remove transitions
display_object:removeSelf(); display_object = nil -- to remove display objects
runtime:removeEventListener() -- to remove runtime listeners
Dispose all audio files when they are no longer needed:
audio.dispose(audio_name); audio_name = nil -- to dispose the audio files.
If you need to set or transition a specific property of several display objects to the same value — for example, fade an entire overlay menu to alpha=0 — it's better to add the objects to a display group and modify the property of the entire group. It's easier to code and it optimizes memory and speed.
While avoiding global variables and functions isn't always possible across the board, minimal usage is the best practice. Access to local variables and functions is simply faster, especially in time-critical routines.
-Thanks
Assif