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 & HelpProcessing Implementations › java.lang.OutOfMemoryError: Java heap space
Page Index Toggle Pages: 1
java.lang.OutOfMemoryError: Java heap space (Read 4884 times)
java.lang.OutOfMemoryError: Java heap space
Dec 30th, 2009, 12:46am
 
I get an out of memory error when i run rp5 run, how can i increase the heap space?
Re: java.lang.OutOfMemoryError: Java heap space
Reply #1 - Dec 31st, 2009, 12:45pm
 
Hey Wilson.

You can put a "java_args.txt" file in your sketch's "data" folder, containing any arguments you wish to pass to the JVM, including heap memory size.

That way, even if you bundle up your sketch as an application, it'll use the correct JVM settings, even when not run from the command line.

This has been mentioned before, regarding stack size, here:
http://processing.org/discourse/yabb2/num_1242228868.html#5

Cheers,
-- Jeremy
Re: java.lang.OutOfMemoryError: Java heap space
Reply #2 - Feb 24th, 2010, 4:35am
 
Hi
i was just running into the same problem, using a lot of video switching with the JMC library:

Exception in thread "JMC MediaProvider EventQueueThread"
java.lang.OutOfMemoryError: Java heap space
Exception in thread "Animation Thread" java.lang.OutOfMemoryError: Java heap space


i increased the memory now with this line:
-Xms528m -Xmx1000m

however, the error occurred after 5,5 hours. it's an application that runs in a terminal for a whole night.
is there a way to monitor/see the heap size while the app is running? like a terminal or console, something like that?

i'm on os x 10.6.2
thanks!

Re: java.lang.OutOfMemoryError: Java heap space
Reply #3 - Feb 24th, 2010, 6:44am
 
Normal JDK comes with JVisualVM application which allows to see the memory and CPU usage of a Java application. I don't know if you have it on Mac OS but it can be downloaded separately.
Re: java.lang.OutOfMemoryError: Java heap space
Reply #4 - Feb 24th, 2010, 3:21pm
 
thanks for that, i also found "jconsole", that also monitors the heap mem and seems a bit more lightweight.

now i was making some tests, but it seems that the memory settings in java_args.txt  totally get ignored. the only setting that affects the heap size is the maximum memory in processing's preferences. also when i export it as an app.

here 2 screenshots.
java_args.txt (located in the scetches 'data' folder) has this setting:
-Xms528m -Xmx1000m

this i get with processing set to 1024MB in preferences:
...

and this with processing set to 24 MB in prefs:
...

seems like 64 is the minimum you can go.
and the 1000M max in the txt file are ignored.

which then lets me wonder: that  sketch that crashed last night after 5,5 hrs already had 1024MB heap size, because i had the preferences set all the time to 1024MB.
how can a crash happen? i let it run again today for 4 hours and heap didn't exceed 60MB.

mhhh.







Re: java.lang.OutOfMemoryError: Java heap space
Reply #5 - Feb 24th, 2010, 11:05pm
 
"i also found "jconsole", that also monitors the heap mem and seems a bit more lightweight."

jconsole is the ancestor of JVisualVM, on Windows both are very small exes, probably running some Java program hiding in jars shipped with JDK...

"it seems that the memory settings in java_args.txt  totally get ignored."

Are you using Ruby Processing? I think rp5 mentioned by OP is that implementation, so the java_args trick probably works only for that.
Re: java.lang.OutOfMemoryError: Java heap space
Reply #6 - Feb 25th, 2010, 1:52am
 
ah no, i didn't see that small r  Smiley
i'm just using the normal processing 1.0.9 for os x.

will make more tests, i still don't know how it came to that error. maybe memory leak in JMC lib. because it seems i can control the maximum heap size in P's preferences, and that's fine with me then. and the 1GB heap space should be more than enough.

Was searching about this topic, but didn't find answers: is there a way to catch that exception and then let the program re-initialize for example some tricks to prevent it to stop
or, at least, to let it quit on the error, and not just to hang then i could use a program like keep-it-up ( http://users.skynet.be/keepitup/ ) to let it get automatically restarted.




Re: java.lang.OutOfMemoryError: Java heap space
Reply #7 - Feb 25th, 2010, 5:10am
 
Quote:
is there a way to catch that exception and then let the program re-initialize for example?

I suppose you can wrap the critical section (JMC calls) with a try { } catch (OutOfMemoryError e) { exit(); }
Or do a periodical action (eg. touch a file) and monitor that with an external utility, killing the process and restarting it if nothing is done for a while.
Page Index Toggle Pages: 1