计算JVM使用情况

public class Memory
{

 public static long usingMemory()
 {
  for(int i=0; i<3; i++)
  {
   System.gc();  
  }
  
  long total = Runtime.getRuntime().totalMemory();
  long free = Runtime.getRuntime().freeMemory();
  
  
  return total - free;
 }
 
 
 

   private final Runtime s_runtime = Runtime.getRuntime();     

}

你可能感兴趣的:(jvm)