简体   繁体   中英

How to retrieve the heap size set in the eclipse.ini file?

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.

在此输入图像描述

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();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM