Thursday, February 7, 2013

Memory Management

Learned some new stuff yesterday about how memory works in Flash. MemoryWhat I thought was a memory leak was not one, instead it was poor memory allocation. When I was destroying objects in Flash (i.e. removing them from the screen) they were in fact not being fully destroyed, their memory footprint remained. Which means that every time someone finished a game and opened a new one, another 228 instances of the tiles were instantiated (created) ontop of the old ones that had not been properly removed from memory.

So basically, as you played the game grew in size. The more memory it took up, the slower the game would begin to play. A really big problem in short.

That is where Flash Builder comes into play. With its handy-dandy profiler tool i can watch in real time the memory allocation of that game, take snapshots of memory at different points in time, compare them, and ultimately discover what in the world is not being destroyed when I tell it too.

Right now, I'm getting pretty close to being perfectly efficient. Still adding about 100-200 K per game to the memory stack, but I should hopefully be able to tackle that problem today.

No comments:

Post a Comment