Reputation: 103
I have set the heap size required in the eclipse.ini
file in the following way:
-Xms256m
-Xmx1024m
Is there any way I could access this value 1024Mb (max heap size) from Java code? Here I do not require the JVM heap size, instead I need the heap size set during eclipse start-up.
One pointer I could find is when I check the Show Heap Status preference in the eclipse preferences, I get a view that shows the current heap usage and the max heap size (value which is set in the eclipse.ini file). Hence I think there is an API which this view uses to read value from the ini file.
Any pointers on the name of the class used to render this heap status monitor view would also be helpful. Please find below the link to the heap status monitor screen shot in eclipse which picks the heap size set in the ini file and displays the same.
Upvotes: 4
Views: 445
Reputation: 111142
The heap status display org.eclipse.ui.internal.HeapStatus
just uses the Java Runtime
class:
Runtime runtime = Runtime.getRuntime();
long totalMem = runtime.totalMemory();
long freeMem = runtime.freeMemory();
long maxMem = runtime.maxMemory();
Upvotes: 3