wood burning stoves 2.0*
The moose likes Java in General and the fly likes java.lang.OutOfMemoryError Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "java.lang.OutOfMemoryError" Watch "java.lang.OutOfMemoryError" New topic
Author

java.lang.OutOfMemoryError

kevin comario
Ranch Hand

Joined: Jun 29, 2002
Posts: 65
I keep getting this error java.lang.OutOfMemoryError. How do i check how much memory the JVM is using and how do change the memory of the JVM? Thanks in advance?
Purushoth Thambu
Ranch Hand

Joined: May 24, 2003
Posts: 425
You can find how much memory JVM is using and available free memory using
java.lang.Runtime class api's totalMemory() and freeMemory(). I am not sure how one can increase the memory for the JVM. It will be more specific to host OS.
David Ulicny
Ranch Hand

Joined: Aug 04, 2004
Posts: 724
You could set it with -X options
if you type java -X it will show you the help, there are two options
-Xms set initial Java heap size and -Xmx set maximum Java heap size.


SCJP<br />SCWCD <br />ICSD(286)<br />MCP 70-216
Luke Knightley
Greenhorn

Joined: Sep 10, 2004
Posts: 3
It's worth mentioning that memory leaks are definitely not impossible in Java. If in your code you (for example) add Objects to a Collection without ever removing them, you will eventually run out of memory. As mentioned in the previous post the -Xms<size> (initial Java heap size) and -Xmx<size> (maximum Java heap size) allow you to set the heap size.
David Ulicny
Ranch Hand

Joined: Aug 04, 2004
Posts: 724
Also static Collection is dangerous.
Ben Wood
Ranch Hand

Joined: Aug 14, 2001
Posts: 342
You can also set this permanently in the Java plugin e.g. on windows Start --> Settings --> control panel --> Java plugin. Click the advanced tab and then stick it in the Java Runtime Parameters field something like

-Xms32m -Xmx256m


SCJP 1.4, www.gsi3d.org.uk
kevin comario
Ranch Hand

Joined: Jun 29, 2002
Posts: 65
Thanks for the help. I'm still trying to figure out what to do but all this points me in the right direction.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java.lang.OutOfMemoryError