Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
jaybionic

VideoLoader memory leak?

Recommended Posts

Alright, so what I am doing is loading in 4 videos and placing them into a 'background' MovieClip. Then when transitioning between the 4 pages, I play a video transition. What I am seeing is that my memory slowly increases on each transition. I have found that it is caused by playing the current video during the transition, and eventually it crashes Flash CS4. Any thoughts on this?

 

Loading code:

_queue.append(new VideoLoader(xml.page[i].@backgroundVideo, { name:xml.page[i].@title, width:1400, height:900, alpha:0, visible:false, container:model.backgroundHolder, autoPlay:false } ));

 

Transition code:

    
var vid_curr:ContentDisplay = ContentDisplay(mainBackground_mc.getChildByName(model.pages[_currPanel]));
var vid_prev:ContentDisplay = ContentDisplay(mainBackground_mc.getChildByName(model.pages[_prevPanel]));

VideoLoader(vid_curr.loader).gotoVideoTime(0);

mainBackground_mc.swapChildren(vid_curr, vid_prev);

var loader:VideoLoader = VideoLoader(vid_curr.loader);
TweenMax.to(vid_prev, 1, { autoAlpha:0 } );
TweenMax.to(vid_curr, 1.25, { autoAlpha:1, loader.playVideo } );

Link to comment
Share on other sites

I think there must be something else going on in your code - I just tried this and there was no memory leak at all:

 

var v1:VideoLoader = new VideoLoader("assets/1.flv", {container:this, autoPlay:false});
var v2:VideoLoader = new VideoLoader("assets/2.f4v", {container:this, autoPlay:false});
v1.load();
v2.load();

var curLoader:VideoLoader = v1;
swap();

function swap():void {
TweenMax.to(curLoader.content, 0.5, {autoAlpha:0, onComplete:curLoader.pauseVideo});
if (curLoader == v1) {
	curLoader = v2;
} else {
	curLoader = v1;
}
addChild(curLoader.content);
curLoader.playVideo();
TweenMax.to(curLoader.content, 0.5, {autoAlpha:1});
TweenLite.delayedCall(2, swap);
trace(System.totalMemory);
}

 

Did you pause the video after it finished transitioning out? And are you using the latest version? http://www.LoaderMax.com

Link to comment
Share on other sites

I have v1.5 of LoaderMax. It is strange, it seems to happen when I try to cast the ContentDisplay var as a VideoLoader type.

 

So when I do just this within my function, I see the memory issue:

var vid_curr:ContentDisplay = ContentDisplay(mainBackground_mc.getChildByName( ("video_"+model.pages[_currPanel]) ));
VideoLoader(vid_curr.loader).gotoVideoTime(0);

 

I'm looking into a solution. I will let you know what I find out. Thanks for the quick reply as well, it got me to look at the problem in another way.

Link to comment
Share on other sites

Hmm, I can't see why casting it would cause any kind of problem. Anyway, when you've got a sample for me to look at, please post it. I'm sure we can get it figured out.

Link to comment
Share on other sites

Ok, here is a stripped down sample to check out (5.5mb so I couldn't attach):

http://sandbox.filterstudios.com/temp/VidTest.zip

 

It seems to happen whenever I try to play the current video. Then the memory gets increased. I can't quite get why either. Take a peek at it when you have a second. I am sure it is something simple. Thanks!

Link to comment
Share on other sites

I can't see a memory leak. It is normal for the System.totalMemory to increase over a period of time until Flash runs a garbage collection sweep (which it does intermittently on its own). I clicked many times and memory increased and then decreased like normal. Of course the first time the video gets rendered in the display object on the stage, it is essentially like a big Bitmap which consumes memory. But once you've clicked all 4 of your nav buttons and the videos have been rendered at least once each, the memory goes up and down normally as far as I can tell. Could you show me exactly how to make the memory increase to the point where it crashes? What must I click on and in what order to see the problem?

Link to comment
Share on other sites

Wow, you have no idea how crazy this is. So on my PC that I usually dev on, it continually increases the memory until Flash crashes. But I just tested on my MAC and it works perfectly! I don't get it, but something is going on with my PC that is not doing the garbage collection properly. Thanks for all the help, I will send you a link to this thing when its done.

Link to comment
Share on other sites

  • 4 years later...

@Jaybionic, did you ever find the root cause of this? I may experiencing something similar. Leaving a looping video running for 24 hours eventually crashes the app on Windows but Mac has no problem. Both machines have the same amount of RAM and both machines are running 64 bit Flash player.

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.
×