The moose likes Java in General and the fly likes increasing  java  heap  size Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "increasing  java  heap  size" Watch "increasing  java  heap  size" New topic
Author

increasing java heap size

durgaprasad ganji
Greenhorn

Joined: Mar 01, 2007
Posts: 7
I am getting below exception when running my java class
java.lang.OutOfMemoryError: Java heap space

pls tell me how to increase JVM heap size for on windows platform

It would be great helpfull anybody send solution for this
Deepak Bala
Bartender

Joined: Feb 24, 2006
Posts: 6592
    
    1

Its very weird that your VM is out of space. Can you post some code ? and what does this have to do with SCJP ?


SCJP 6 articles - SCJP 5/6 mock exams - SCJP Mocks - SCJP 5 Mock exam (Word document ) - SCJP 5 Mock exam in Java.Inquisition format
Srinivasan thoyyeti
Ranch Hand

Joined: Feb 15, 2007
Posts: 557
Hi durga,
Could you please tell me snapshot of how many applications you are running ?
How much RAM you have?

1)Try to exit all remaining programs ...
2)You can checkout the free memory using Runtime Class.


Thanks & Regards,<br />T.Srinivasan,<br />SCWCD 1.4(89%),SCJP 5.0(75%)<br />"That service is the noblest which is rendered for its own sake." - Mahatma Gandhi
Yuriy Zilbergleyt
Ranch Hand

Joined: Dec 13, 2004
Posts: 429
Originally posted by Srinivasan thoyyeti:
Hi durga,
Could you please tell me snapshot of how many applications you are running ?
How much RAM you have?

1)Try to exit all remaining programs ...
2)You can checkout the free memory using Runtime Class.


I thought JVMs usually start up with a set amount of memory reserved, so as long as on JVM start up you have enough memory, opening a million other programs later on would not cause a Java out of memory error. Am I wrong?

Yuriy
Jesper de Jong
Java Cowboy
Bartender

Joined: Aug 16, 2005
Posts: 12929
    
    3

How you can set the heap size is described in the documentation. Use the -Xmx... option to set the maximum amount of memory that the JVM will allocate.

But really, instead of just setting the heap size larger, you should have a look at your code and find out why you are getting an OutOfMemoryError. Does your program really need to allocate so much memory or do you have a bug somewhere in your code?


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: increasing java heap size
 
Similar Threads
Limit of Memory size
Heap size in Java
SIGSEGV 11 / SIGABRT 6
JVM Size
Tomcat and Optimizeit throwing Out of memory error