wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes OutofMemoryError Java Heap Space 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 Java Heap Space" Watch "OutofMemoryError Java Heap Space" New topic
Author

OutofMemoryError Java Heap Space

Jim Ball
Greenhorn

Joined: Dec 05, 2006
Posts: 8
To correct this error I can simply increase the JVM's heap size. My question is how can I increase the JVM's heap size efficiently so I do not over allocate? Are there steps to follow to see approximately how much heap size (memory space) I need for my program? Any assistance would be greatly appreciated.

Thanks,

Jim
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
One quick way to get an idea how much memory your program uses is to invoke java using the -verbose:gc option:

java -verbose:gc MyClass

You will get messages to standard output describing how the memory use goes up and down, and how it's affected by GC. However note that it's always possible that GC could have collected more, at any given time. If you over-allocate memory, it's possible the JVM will use it just because it's available, and the GC won't necessarily try so hard to free up memory until you approach the limit. So you should also experiment a bit with changing the -mx parameter, just to see what happens.


"I'm not back." - Bill Harding, Twister
 
wood burning stoves
 
subject: OutofMemoryError Java Heap Space
 
Similar Threads
Command line options in TextPad
Exectuion throwing Out of Memory exception
Increase JVM heap size of eclipse
Eclipse 3.2 Increase Heap?
Out of memory error