How to get heap size set in eclipse.ini file?

I set the heap size needed in the file eclipse.inias follows:

-Xms256m
-Xmx1024m

Is there a way to access this value of 1024 MB (maximum heap size) from Java code? Here I do not need the JVM heap size, instead I need the heap size set during eclipse startup.

One pointer that I could find is when I check the Show Heap Status preference in eclipse settings, I get a view showing the current heap usage and maximum heap size (the value set in the eclipse.ini file). Therefore, I think there is an API that this view uses to read values ​​from an ini file.

Any pointers to the class name used to display this heap state monitor will also be helpful. Below is a link to the heap state monitor screen taken in eclipse, which selects the heap size specified in the ini file and displays the same.

enter image description here

+4
source share
1 answer

Heap state mapping org.eclipse.ui.internal.HeapStatusjust uses the Java class Runtime:

Runtime runtime = Runtime.getRuntime();
long totalMem = runtime.totalMemory();
long freeMem = runtime.freeMemory();
long maxMem = runtime.maxMemory();
+3
source

Source: https://habr.com/ru/post/1625261/


All Articles