This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes OutOfMemoryError Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "OutOfMemoryError" Watch "OutOfMemoryError" New topic


martin klima

Joined: Apr 22, 2005
Posts: 2
When running my Java application, JVM often causes an OutOfMemoryError with message "Java heap space". This application needs about 100MB of memory, I run it on WinXP platform with 1GB memory installed. How can I prevent this error? Can I somehow extend the heap space used by my application? Thank you in advance.
David Ulicny
Ranch Hand

Joined: Aug 04, 2004
Posts: 724
You can use -Xmx and -Xms switches from command line.

java -Xms256M -Xmx512M yourClass

check java -X

-Xmx maximum heap size
-Xms initial heap size

SCJP<br />SCWCD <br />ICSD(286)<br />MCP 70-216
wood burning stoves
subject: OutOfMemoryError