I wonder if I can get the maximum allocated heap size using the VM command line.
Now I can get it using Netbeans Profiler , but I prefer to get the result without having to run an additional application.
I also use this method:
public void printMemUsage(){ double currentMemory = ( (double)((double)(Runtime.getRuntime().totalMemory()/1024.0)))- ((double)((double)(Runtime.getRuntime().freeMemory()/1024.0))); System.out.println("Current memory usage in kilobytes :"+currentMemory); }
I think I can use this to get the maximum heap size, but I'm not sure if it is very reliable.
I am currently using these command lines:
-verbose: gc -XX: + PrintGCDetails -XX: + PrintGCApplicationConcurrentTime -XX: + PrintGCApplicationStoppedTime
To get good information about the activities of gc, the young generation, the old and the constant. But I can just tell the current full heap space when the collection occurs.
So, is there a way to get the maximum heap space that has been allocated using other commands?
source share