File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
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
I agree. Here's the link:
subject: OutOfMemoryError
It's not a secret anymore!