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 › Dumping memory
Page Index Toggle Pages: 1
Dumping memory (Read 646 times)
Dumping memory
Aug 31st, 2006, 2:08pm
 
Hi,
I'm using a program which loads a lot of images.
Is there any way to dump the image from memory once we're done using it?
Thanks Smiley
Re: Dumping memory
Reply #1 - Aug 31st, 2006, 3:10pm
 
If you remove all references to the image, e.g. set the PImage variable to null, then eventually Java's garbage collector will free the memory.
Re: Dumping memory
Reply #2 - Aug 31st, 2006, 10:35pm
 
Is there a way (other than some guessing by looking at Task Manager on Windows) to println() the current memory usage and free memory?
Re: Dumping memory
Reply #4 - Sep 1st, 2006, 6:07am
 
Thanks for coming to my rescue again John Smiley
Re: Dumping memory
Reply #5 - Sep 1st, 2006, 1:40pm
 
Thanks.

Because it took me at least ten tries to get the right syntax I reproduce it here for the sake of sanity.
Code:
println(Runtime.getRuntime().freeMemory()); 

Re: Dumping memory
Reply #6 - Sep 2nd, 2006, 7:42am
 
Thanks for posting that code st33d. Very useful! Smiley
Re: Dumping memory
Reply #7 - Sep 2nd, 2006, 7:11pm
 
On a side note, you might want to do something like:
Code:
Runtime rt;
void start() {
rt = Runtime.getRuntime();
}

(Then use rt.freeMemory() and rt.totalMemory() as needed.)

It probably won't make a huge difference on today's computers, but it would avoid some redundant steps.

Marcello
Page Index Toggle Pages: 1