This is the sequel of this thread: How to restart a level (dispose of previous one) without memory leak? - Questions & Answers - HTML5 Game Devs Forum
To summarise the previous thread: I made a piece of code that runs a loop where it:
- generates a maze,
- displays it for few seconds,
- disposes of the scene and the UI (advance texture)
I’ve got some evidence that there is a memory leak because, after some iterations the framerate drops and the CPU load increased.
To make a PG example of my problem is a bit complicated because I basically need a lot of my functions/objects/textures/assets to run the example.
Hence, instead I made a branch on Bitbucket that you can clone, but I can not share it publicly, so you would need to PM me if you’re interested in having a look (yeah, I am decreasing all my chances to be helped! sorry ).
I realised that last time, I had the inspector opened! hence that may be why the CPU was bloated!
I re-run my test without the inspector (and some optimisation using mergeMeshes() / SPS), that works much better in term of CPU, but we can still see a leak after few scene reloads.
Here the first few scene reloads. You can see that the CPU is at 100% when I load the maze, then the processor relaxes during the game (yellow curve in the top graph), the FPS is at 0 during the loading time (cause 1 static image) and ~60 during the game (the green curve in the top graph).