As I'm playing my game, the RAM usage goes higher and higher.
That's ok, because I spawn objects and stuff and I have to update more stuff at once.
However when I change gamestate, I clear the tables which contained the objects and everything. Still the ram usage doesn't decrease.
It seems like a garbage collector problem?
How do I force the game to destroy stuff?
On Pc it isn't a problem. It has a 600mb RAM peak, it doesn't go higher, but on mobile it could be a problem.
When the day ends, I reset stuff and change gamestate.
Shame on me for not using a gamestate lib, but I'm so ahead in the development that I'd prefer to solve my problem manually.
I guess I'm doing something different from a gamestate library at this point
Code: Select all
if day == false then
backgroundMusicSummer:stop()
nightSummer.alpha = 0
playerSummer.x = wWidth / 2
camera.x = 0
trees = {}
stones = {}
statues = {}
day = true
gamestate = "level3"
else
if introFadeInSummer.ended == false then
introFadeInSummer:update(dt)
end
backgroundMusicSummer:update(dt)
spawnTreeSummer(dt)
collisionsTreeSummer()