Huge Memory leak on iOS

Monkey Forums/Monkey Programming/Huge Memory leak on iOS

Grey Alien(Posted 2013) [#1]
Hi all, sorry if this is a noobish topic. I searched the forums and read many posts but couldn't find any help.

Basically I found out today that my iOS app is not freeing up memory by the looks of things. I rapidly alternated between two screens and the the game bombed. I used Instruments on my Mac and could see the app memory go about by around 2Mb per screen swap.

When I move to a new screen in my game I set the field pointing to the main image on the old screen to null and then load in the new image for the new screen. It's the same method I've used for years on PC, but it seems that this causes a huge memory leak on iOS. If I comment out the image loading there is still a leak when changing screens but it is smaller. Also the memory use seems to creep up a bit just as the game is idling.

I also used Activity Monitor on Mac to view memory use for the GLFW app and it too goes up a tiny bit with repeated screen swaps but seems to stop at about 45Mb, maybe, it's a bit hard to tell.

I just noticed that if I let the game idle on iOS for a bit and then go back to it the mem use has dropped down again. Seems like the GC doesn't kick in every update which is risky if you did a lot of creating/freeing memory in sequence especially on devices like iPad 1 where if you go over about 90Mb mem use it'll crash (I know this from working on other C++ projects and talking to other devs who confirm the same)


Volker(Posted 2013) [#2]
* A fix for images not discarding themselves quickly enough due to incremental GC. Also copied some of the new v67 GC in...

Mini-update for V66 thread.


Grey Alien(Posted 2013) [#3]
Ah perfect, will try out tomorrow. Thx!