Skip to main content
April 16, 2013
Question

Scrubbing Movie Clip Fills Memory, Crashes Flash

  • April 16, 2013
  • 1 reply
  • 2861 views

Hello,

We have a Flex 4/Actionscript 3 application that involves "scrubbing" through a Movie Clip that is a swf file derived from a .mov file.  This is accomplished by listenening to the change in value of an HSlider and calling gotoAndStop(n) on the Movie Clip repeatedly as the slider is dragged.  The Movie Clip is 720 pixels wide by 405 pixels high.

It works great, however, after doing this scrubbing action a number of times, which is required by our application, we notice the memory (by tracing System.totalMemory and System.privateMemory) increasing dramatically; and when it gets to around 100 MB (though it's not the same every time), the Flash plugin in the browser will crash.  Our assumption is that this happens because the scrubbing essentially loads dozens of bitmaps (each frame of the Movie Clip that is scrubbed over) very rapidly.

To try and ameliorate this, we have implemented aggressive garbage collection by calling System.pauseForGCIfCollectionImminent(0.1) on a timer every 10 seconds.  This usually keeps Flash from crashing, however, sometimes the garbage collection itself causes Flash to crash, though it's not 100% predictable.  We know this because we are tracing the garbage collection action and can see Flash crash when that action occurs.

It doesn't seem like we have a memory leak per se, as the free memory is eventually regained when forcing garbage collection.

So I have a couple of questions:

1) Is there any way to keep the memory from getting so large in the first place, given that we need this scrubbing functionality?

2) If not, is there a better way of tweaking the garbage collection so that it frees up memory while not itself causing Flash to crash?

This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
April 16, 2013

are you sure there's nothing else (like actionscript) on those frames through which you're scrubbing?

April 16, 2013

kglad,

If you mean in the sense of actionscript embedded on a frame in a timeline -- no, there is nothing like that.  This is a Flex/AS3/FlashBuilder built app, no timelines or anything.

I'm curious as to why simply playing the Movie Clip does not seem to cause the memory to increase, while the scrubbing action (which calls gotoAndStop on each frame) does cause the memory to increase.  It is essentially doing the same thing, loading and unloading a series of bitmaps.

kglad
Community Expert
Community Expert
April 16, 2013

copy and paste the code you're using.