Question

I am using eclipse EE in ubuntu by downloading the .tar.gz file from eclipse website and extracting in my home directory. I set the -Xmx to 3072m in the eclipse.ini. Here it is:

-startup
plugins/org.eclipse.equinox.launcher_1.1.0.v20100507.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.gtk.linux.x86_64_1.1.1.R36x_v20100810
-product
org.eclipse.epp.package.jee.product
--launcher.defaultAction
openFile
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
256m
--launcher.defaultAction
openFile
-vmargs
-Dosgi.requiredJavaVersion=1.5
-XX:MaxPermSize=256m
-Xms2048m
-Xmx3072m

But when I am trying to see my total memory by

Runtime.getRuntime().totalMemory()

It is returning 62193664 that is 59mb. I also tried to launch eclipse from terminal setting vmagrs, but nothing changed. I don't know what is happening. How can I set the heap size? My total ram is 4gb and I using 64bit Ubuntu with 64bit eclipse. Any information will be very helpful to me.

Was it helpful?

Solution

1) The Runtime.getRuntime().totalMemory() does not return the maximum allowed heap size.

2) I'm not sure how do you run Runtime.getRuntime().totalMemory() but I guess you do that from within your Eclipse in a Java application. In this case you execute the call in another JVM which does not inherit properties from your eclipse.ini file. If you want to determine the initial and max heap size for it you can go to Run->Run Configurations.... Click on your current run configuration and in the right pane click on the Arguments tab. There you may specify the VM arguments, e.g.:

-Xms64m
-Xmx1024m 

Afterwards you may continue experimenting with the Runtime. eclipse.ini configures the resources for the Eclipse IDE not for the Java application that you run.

Cheers!

OTHER TIPS

In short, Runtime.getRuntime().totalMemory() is useless, it returns the size of one GC generation.

This thread has an explanation: http://mail.openjdk.java.net/pipermail/hotspot-gc-use/2008-December/000318.html

Thank you. So the solution is setting VM Arguments from Run->Run Configurations in eclipse. I had set it to -Xms3072m -Xmx3072m and now the Runtime totalMemory() is returning 3087007744 that is 2944MB in 4gb ram with 64 bit Ubuntu 10.10 and 64 bit JVM.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top