We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › garbage disposal
Page Index Toggle Pages: 1
garbage disposal? (Read 518 times)
garbage disposal?
Jun 19th, 2008, 7:58am
 
hey guys.  i'm using a processing sketch at the moment to do some video in/out.


the idea is an "indirect" feedback loop.  so i have a projector beaming on to a wall and a camera recording that projection, but instead of feeding them straight through to each other, there's a delay.

a Movie object plays a .MOV through to the projector.  a Capture object captures this projection from a camera, and then a MovieMaker object passes these captured frames into a .MOV file.  but in my draw() function i call the image(myMovie) LAST, so the projection doesn't display the bits being recorded by the camera, just the first MOV.

following?  


after 20 seconds, i finish() the MovieMaker, load that newly created MOV into the Movie object and begin capturing a new one with the MovieMaker.  i do this by calling the constructor again on the old MovieMaker and Movie objects.


the problem is each iteration gets slower, framerates dropping.  eventually the whole thing crahses from a lack of memory.  so obviously this is the wrong way to do it.  

but if i have a Movie object and a MovieMaker object, how do i make them point at different MOV files without just saying "myMovie = new ...." and "myMovieMaker = new....", assuming this is the problem?  do i need to free up the memory previously used by their old instances somehow?


urgh.  this is confusing, hope it makes sense.  all help appreciated.
Re: garbage disposal?
Reply #1 - Jul 31st, 2008, 10:19pm
 
If I understand correctly you want to save individual movie snippets instead of having MovieMaker constantly writing into one file, making it huge.

If you want to cut off the files at regular intervals you could do something like:

if(frameCount%500 == 0) {

finish() your MovieMaker inside the if and start a new one using a string variable perhaps taken from the system date as the filename.
Re: garbage disposal?
Reply #2 - Aug 1st, 2008, 12:58am
 
That's what I'm doing, but I'm starting a new one by constructing a new MovieMaker object, which seems to be what's causing the memory leak.  Is there another way to do it, without calling "myMovie = new MovieMaker(blah blah blah)..."

?
Re: garbage disposal?
Reply #3 - Aug 1st, 2008, 1:23am
 
I see no flaw in your method: by using mm = new MovieMaker(xxx), the old object should loose any reference (if you don't have another variable holding it) and should be collected.
Perhaps you can try and help Java knowing it should collect these by doing something like:

mm = null;
System.gc();

after finish(), before creating a new object.
Page Index Toggle Pages: 1