Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

So I'm working on a puzzle game in flash. For all intents and purposes it's like Tetris. I spawn blocks, they move around the screen, then they get destroyed and disappear. I was having some trouble with the memory usage being too high over time so I read up on memory management and I think I have that figured out now. It's definitely climbing slower than it was before, but the framerate is still taking a huge dive after playing for a while. If it's not a memory leak what else could be causing this? Thanks in advance.

share|improve this question
up vote 4 down vote accepted

Either 2 of these it think:
- It would very well be that you are deleting stuff from the display-list but still have references in other places( like arrays ) that are still being processed. This keeps building up and completely hogs your game. ( but Flash can easily handle tons of objects )


-Your algorithm, even though simplistic, is flawed and is doing more work than necessary. Memory leaks are nearly impossible in AS3 unless you loose an object that holds a reference to an object you can't reach anymore ( like Events that aren't destroyed and never have their weak flag set to true).

This combined with the above one can really tear down the performance.

share|improve this answer
Hmm, at what amount of memory do you think the game could no longer handle 30 FPS? Because the game stays around 30 and no higher than 40. – Cyborg771 Aug 8 '12 at 2:44
It's not the amount of memory, rather the object your game needs to process. Keeping stuff in memory but not doing anything with them shouldn't directly affect the performance unless you do something with it. If your objects aren't rendering after removal, then you took them out of your display list. But you should also check if they are removed from arrays etc. The Garbage collector will only destroy the data if exactly 0 pointers are pointing to the data. – Sidar Aug 8 '12 at 2:48
I'm fairly sure I've taken care of this. Every time I destroy a block it looks like this: blockHolder.removeChild(block); delete(block); blocks.splice(blockIndex, 1); – Cyborg771 Aug 8 '12 at 2:59
Seems to be clean. What software are you using? Flashdevelop for example has a profiler which allows you to see various stats on object types, like the amount that are in memory. – Sidar Aug 8 '12 at 3:07
I'm just using Flash CS5 but I am currently using thMiner profiler but I don't really know what I'm doing with it or what I should be looking for. – Cyborg771 Aug 8 '12 at 3:13 you should visit this part of that tutorial, it will probably contain your problem, which is for example, not unloading the childs you create and instead just freeze them out of view. I could try to tell you details but check that out, at least you should get a lot of really useful tips.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.