Game slowly lags to death

This is an issue that I’ve run into over and over again, and it just drives me insane. Whenever I make a game which stays on one frame for a while (lots of dynamic objects are made, particle effects, bla bla), the framerate very very slowly starts to drag. After a few minutes, it’s at about half what it started at, and it steadily drops until the game is unplayable.

I have no idea what’s wrong. I use some variation of the following code to clean up dead movieclips:


e.currentTarget.visible=false;
e.currentTarget.removeEventListener(Event.ENTER_FRAME, moveThing);
e.currentTarget.parent.removeChild(e.currentTarget);

I guess I should mention that I do contain references to the movieclips in arrays, but I splice them out. Is that ok?

I’m almost positive that somehow Flash is still keeping track of my old movie clips, even though I feel like I’m getting rid of them. Is there something wrong? Do I have to do some extra special magic to totally banish them forever? Please help. This has been driving me insane.