Hi! I’m working in a game with asteroids.
I have a problem with the memory usage: My game spawn around 50 asteroids at once. Then, when I “Restart” the game, I delete the asteroids by:
aux = 0
for i = 1, cuentaasteroides do
aux = aux +1
display.remove(asteroide[aux])
asteroide[aux] = nil
end
But when appear other 50 asteroids (in the “restarted” game), other 70 kb of memory are used, and so on. If I change 50 asteroids to 500, that extra is of 700 kb. That’s why I think that the trouble are the asteroids.
If I continue the game become slow almost to collapse
Note: I check the memory using this function, that I found in the Corona Tutorials:
local function checkMemory()
collectgarbage( “collect” )
local memUsage_str = string.format( “MEMORY = %.3f KB”, collectgarbage( “count” ) )
print( memUsage_str, "TEXTURE = "…(system.getInfo(“textureMemoryUsed”) / (1024 * 1024) ) )
end
darmemoria =timer.performWithDelay( 1000, checkMemory, 0 )
Can someone help me? Thanks in advance!