5

I have a following problem. When I try to raise memory for JVM in eclipse.ini file, I always get Could not create Java Virtual Machine exception.

My current memory settings are

-Xms1024m
-Xmx1024m
-Xmn256m
-Xss2m

And I would like to raise them to

-Xms2048m 
-Xmx2048m
-Xmn512m
-Xss2m

I am running on 32-bit Java, JDK 1.6. I have a 64-bit machine with 12GB of memory. The reason I am not using a 64-bit Java is that we have encountered some problemes during develepment of our apps, so we switched back to 32-bit one.

Thanks a lot for advices.

EDIT

Ok, so here is my stack trace, it occurs when I try to run Eclipse. Also notice that I have Xms parameter set only to 512M but it works when it's set to 1024M, but it seems too much for one (even big) web app.

enter image description here

Petr Mensik
  • 26,874
  • 17
  • 90
  • 115
  • 1
    I believe that the 32-bits version can only go up to 1.5G of memory – Guillaume Polet Apr 18 '12 at 07:08
  • 2
    See http://stackoverflow.com/q/171205/651140 – Andrzej Jozwik Apr 18 '12 at 07:09
  • See also limits [Sizing the Java heap](http://publib.boulder.ibm.com/infocenter/javasdk/tools/index.jsp?topic=%2Fcom.ibm.java.doc.igaa%2F_1vg00014884d287-11c3fb28dae-7ff6_1001.html) – Andrzej Jozwik Apr 18 '12 at 07:11
  • My advice is.. `-Xms1024m -Xmx1024m` ..set the `-Xms` value to a much smaller number than `-Xmx`. Not the problem here, just a good idea not to presume the app. is going to **need** all that memory. – Andrew Thompson Apr 18 '12 at 07:12
  • @ajozwik - it is worth noting that that page is rather old. In my experience with more recent JVMs and Linux, you don't need a special kernel to go to a >2Gb heap. It would appear that "Hugemem Kernel" is standard for 32-bit Linux these days. The page also doesn't mention that some versions of 32-bit Windows can be configured to use PAE ... – Stephen C Apr 18 '12 at 07:39

1 Answers1

8

For one thing, you should never set your Xms to the same amount as Xmx because this will effectively cause the garbage collector to never run until your Java VM memory is completely used up. Set Xmx to the maximum memory you want to allocate to the Java applications and VM, and Xms to the maximum amount of memory the VM should use without bothering too much to garbage collect. You may find this will solve your problem.

Renato
  • 12,940
  • 3
  • 54
  • 85
  • *"You may find this will solve your problem."* I doubt that, but +1 for everything before it. – Andrew Thompson Apr 18 '12 at 07:14
  • Thanks for advice, sounds reasonable:-) – Petr Mensik Apr 18 '12 at 07:15
  • The problem may actually be that the 32-bit VM cannot even allocate more than 2GB. I had a similar problem with that before, but the problem only showed up during run-time..... not sure exactly why it would happen on start up.... – Renato Apr 18 '12 at 07:17
  • If you show your stack trace that might help find the source of the problem. – Renato Apr 18 '12 at 07:22