Skip to main content
Participating Frequently
September 22, 2011
Question

Vector animations memory leak - Air for Android

  • September 22, 2011
  • 1 reply
  • 789 views

I'll try and keep it quick...

I am developing an app for Android using Flash and have a few vector animation states for the main character. For now I have to keep these animations as vector because I need individual control over parts of the animation.

If I stick on the idle animation I see the memory usage go up around 0.1MB per second and that keeps ticking away consistently. (This is on the PC test for now).

If I change to the flying animation for a second and then back to the idle the memory starts going up 0.4MB per second.

Even though I've changed back to the original animation memory keeps rising by the larger rate. For each extra animation I switch to the rate of increase gets larger.

Testing on my HTC Desire HD the rate appear massively greater than the PC. On idle it raises 0.2MB per second and with switching it to flying then back gets up to 3MB per second.

For some background info, each animation state is a movieclip placed along the one timeline, one keyframe per state. This means I'm using an ordinary gotoAndStop commands to switch animation states. These animations have no code past a stop() command.

I've narrowed the leak to these animations because if I turn off the animation switching there's no increase (past the idle rate).

While the rate is manageable on PC it causes massive performance issues on the phone and I'm attempting to solve this without forcing garbage collection.

Any thoughts?

This topic has been closed for replies.

1 reply

Participating Frequently
September 22, 2011

So some further investigation into this issue I have found that each animation frame updated gets added to the memory usage. This sort of makes sense that each frame updated adds to the memory consumed. If I use a static frame for the idle state instead of an animation, the memory stops increasing.

However, if each frame of my idle animation consumes 0.1MB of memory per second and the flying animation consumes 0.4MB per second, why doesn't it go back to consuming only 0.1MB per second when I switch back to the idle animation. It's as though the flying animation is still animating in memory when it's definitely not in the display list any more.