This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach 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 Murach's Java Servlets and JSP this week in the Servlets 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
Consider Paul's rocket mass heater.
subject: OutOfMemoryError
Similar Threads
Passed with 348/400
Garbage collection in glassfish
OutOfMemoryErrors and the native heap
Out of memory error:java heap space ?
Advanced performance adjustments for Tomcat