Jump to content
Search Community

XMLLoader, videos and RAM = memory leak?

Mr Pablo test
Moderator Tag

Recommended Posts

OK, so to cut a long story short, I'm back to using building my app in Air for Android (video playback issues in Flex halted Flex Mobile development).

 

I built a bare-bones LoaderMax app that loads 2 videos (.mp4's - .flv's were choppy?!?!) and plays them one after the other.

 

I added a memory counter to the stage to show both totalMemory and privateMemory (I am displaying both because I'm not 100% sure which is relevant to the actual app) and the memory count slowly creeps up.

 

Is there something wrong with the way I am handling the videos e.g. adding/removing them from the stage (just remove from view, not from the LoaderMax)

 

I have attached the project fla and XMLLoader xml file. Just find a couple of mp4 videos (mine are 720p,  and a few mb so I can't upload them)

 

The videos play fine (no stuttering) but there are some noticeable oddities after a while (from adding and removing I think) and you can see the last frame of the previous video etc

Link to comment
Share on other sites

You didn't include the assets so we couldn't effectively test on our end, but I will mention a few things:

  1. It is completely normal for memory usage to steadily increase, but then at some point garbage collection kicks in and memory usage should drop a bit and then start rising again. 
  2. You are adding an ENTER_FRAME event listener (and VideoLoader has one internally too) which means that on every frame, an Event object is created and dispatched by Flash. Each of those Event instances takes up memory. This is nothing to be afraid of really, unless you're keeping references to those events (I'm sure you're not). But that's one of the reasons memory usage goes up over time. When gc kicks in, it will sweep those away (all the ones that don't have an active reference tied back to something in your app that needs it). 
  3. Minor thing: You're removing the VideoLoader.VIDEO_COMPLETE event listener from the root instead of the actual VideoLoader instance, so the listener never gets removed. That would prevent the VideoLoader from being garbage collected (since there is an active event listener attached). 
  4. If you don't want the video to show (you said the last frame was visible sometimes), you can either set visible to false on the ContentDisplay or remove it from the display list or clear() the Video (which is the ContentDisplay's rawContent). 
Link to comment
Share on other sites

3) yourVideoLoader.removeEventListener(VideoLoader.VIDEO_COMPLETE, onVideoComplete);

 

4) No, if you call clear() on a Video instance (not a VideoLoader - I'm talking about a regular Flash Video instance), it just clears the graphic off the display. See Adobe's docs for more details. 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...