AIR iOS Memory Management Unavoidable

I’m still working on my IOS game and continually see it crash. Crash meaning it will just go black and back to the main menu. Soon I discovered that memory management is now more important than ever. If you think the garbage collector is working, it’s actually not. You’ve just been lucky that your computer didn’t run out of memory by the time it shut down.

When it comes to mobile there is no avoiding this, and at times its even harder than normal memory management. Everything you NEW you must null when you’re done. And that’s not enough, you also have to remove all listeners, dispose all bitmaps, null all sounds. Too bad, I wanted to avoid memory management, Objective C was a nightmare.

Learn how to change your code here:

Then afterwards, learn about putting Flash Preload Profiler into your projects:

Happy garbage-marking!!

UPDATE#1: I’ve had a lot of problems here, my game never cleans up its garbage even on the normal Flash player. Some movieclips never get cleaned up, the profiler says there’s 100 instances. And I nulled/delete/dispose/removeEventListener the crap of it. No luck yet.

UPDATE#2: I’m moving to Corona SDK. Bye Flash, I still need you for my day job.

One comment

  1. jpauclair says:

    Since a few months now, all flash player version have been updated with the unability to report correctly “delete object sample”. The result of this is the “current number” of instances seem to never go down when in fact they do.

    It’s mostly the case for Sprite / DisplayObject, but it can also apply to events and a few other data type.

    Vote for this bug: