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 › How to trace a memory leak
Page Index Toggle Pages: 1
How to trace a memory leak? (Read 1543 times)
How to trace a memory leak?
Nov 1st, 2007, 8:32pm
 
I have a (mostly) working processing sketch that, after a certain point in its' execution, begins hemorrhaging memory. I think it might have something to do with re-using the same Movie object, but I'm not certain.  I'm not familiar with java debug tools, but I know something must exist to allow me to track what objects are using what memory, etc. Can anyone offer some advice on techniques or tools I might use?
Re: How to trace a memory leak?
Reply #1 - Nov 2nd, 2007, 4:03am
 
Just replying to myself: the issue (or at least the first part of the issue) turned out to not be a memory leak, but rather that I wasn't calling stop() on my Movie object before setting it to null. Consequently, the movieEvent callback was called once per frame for each movie that was ever viewed! Not a pleasant thing for stability.

I'm still curious what methods I might use to determine this other than dumb luck and poking at my code..
Re: How to trace a memory leak?
Reply #2 - Nov 2nd, 2007, 7:54pm
 
It's kind of a long-stretched solution but I might as well suggest it.

Try rebuilding your app for Eclipse (an effort itself lol!) and then run a profiler with it. If you are on MacOSX a great utility is to Shark which lets you see memory usage patterns, what lines of code are eating up process time... etc.

~M
Re: How to trace a memory leak?
Reply #3 - Nov 3rd, 2007, 5:38pm
 
I am indeed on OS X, and I've been thinking that I need to rebuild for Eclipse anyway, so I can build an app that'll run without the P5 GUI installed.  I'll give this a try over the next several days and report back!

(For right now, one further question: When I leave my sketch running and walk away, after some indeterminant period of time, it errors with the following error:

java(515,0xa000ed88) malloc: ***  Deallocation of a pointer not malloced: 0xffffffff; This could be a double free(), or free() called with the middle of an allocated block; Try setting environment variable MallocHelp to see tools to help debug
java(515,0x183b200) malloc: *** error for object 0xb60f120: double free
java(515,0x183b200) malloc: *** set a breakpoint in szone_error to debug
java(515,0xa000ed88) malloc: ***  Deallocation of a pointer not malloced: 0xffffffff; This could be a double free(), or free() called with the middle of an allocated block; Try setting environment variable MallocHelp to see tools to help debug
java(515,0x183b200) malloc: ***  Deallocation of a pointer not malloced: 0xb6095f0; This could be a double free(), or free() called with the middle of an allocated block; Try setting environment variable MallocHelp to see tools to help debug
java(515,0xa000ed88) malloc: *** error for object 0x3338a0: double free
java(515,0xa000ed88) malloc: *** set a breakpoint in szone_error to debug
java(515,0xa000ed88) malloc: ***  Deallocation of a pointer not malloced: 0xffffffff; This could be a double free(), or free() called with the middle of an allocated block; Try setting environment variable MallocHelp to see tools to help debug

Any idea what would cause this? I have to assume it's in a library (I'm only using ControlP5 in this application) or the P5 core, because I'm not directly calling malloc() or free() in my code..
Re: How to trace a memory leak?
Reply #4 - Nov 3rd, 2007, 6:46pm
 
Alterscape wrote on Nov 3rd, 2007, 5:38pm:
I am indeed on OS X, and I've been thinking that I need to rebuild for Eclipse anyway, so I can build an app that'll run without the P5 GUI installed.  

does export to application not work
Re: How to trace a memory leak?
Reply #5 - Mar 8th, 2009, 4:22am
 
I'm also seeing a memory leak, but calling stop() doesn't seem to be helping. I've posted some basic examples, here:

http://ericnguyen.com/processing/movietests/

One uses the Processing video libs, the other uses JMCMovie, a much faster library (http://www.mat.ucsb.edu/~a.forbes/PROCESSING/jmcvideo/jmcvideo.html). Both are leaking memory, so I suspect that I'm just making a n00b error. If I simply loop the movie rather than loading it anew each time, there's no memory leak.

Any help would be appreciated. I'm working on an art installation that will string videos together, with fade transitions between.

Thanks!
Re: How to trace a memory leak?
Reply #6 - Mar 8th, 2009, 4:34am
 
Note: I've found that JMCMovie.switchVideo() doesn't leak memory, but this isn't ideal for other reasons.
Re: How to trace a memory leak?
Reply #7 - Mar 21st, 2009, 4:15pm
 
I can't find any help on how to use the JMCMovie.switchVideo(), could anyone just post a simple explanation? Much appreciated! And a much appriciated lib too!
Re: How to trace a memory leak?
Reply #8 - Mar 23rd, 2009, 8:25pm
 
You can find documentation for all of the JMCVideo classes here:

  http://www.mat.ucsb.edu/~a.forbes/PROCESSING/jmcvideo/javadocs/

I found, though, that switchVideo required the full path to the files I was using. Perhaps the library author will address this!

~e
Re: How to trace a memory leak?
Reply #9 - Mar 23rd, 2009, 8:51pm
 
Thanks enguyen for the doc! But I'm sorry I still don't get how to use it properly. I unfortunately suck at Java...

In the method that is goes like this:

public void switchVideo(java.lang.String filename)

what is "java.lang.String"? should I use "this" here or am I confused?

could you give me a short code example on how to use this method?  

Re: How to trace a memory leak?
Reply #10 - Mar 23rd, 2009, 8:56pm
 
Ah. It looks like your Java knowledge is more basic than I thought. Well, I can't get into a whole tutorial or anything, but basically "java.lang.String" is the "type" of the parameter to pass in and "file" is the name of that parameter.

You want to pass in your own string that is the file name. I noted in my comment that the file name unfortunately needs to have the whole path, so here's an example:

movie.switchVideo("/path/to/my/file.mov");

Sorry I can't be of more help. Good luck!
Re: How to trace a memory leak?
Reply #11 - Mar 23rd, 2009, 11:21pm
 
Hi, I am the author of the jmcvideo JMC bindings. I have made some updates which should resolve the switchVideo issue and the memory leak. For convenience, I am posting my detailed response in the jmcvideo thread.

http://processing.org/discourse/yabb_beta/YaBB.cgi?board=Video;action=display;num=1231145469

HTH, Angus


Page Index Toggle Pages: 1