仮想マシンのメモリを取得し、印刷します

hadoop@slave2:~/Desktop/VOiceInterface$ cat test.java 
public class test {
	
	public static void main(String[] args) {
		try {
			
			long aa = Runtime.getRuntime().maxMemory();
			System.out.println("JVM-max:"+aa);
			
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}
	}

}
hadoop@slave2:~/Desktop/VOiceInterface$

結果:

hadoop@slave2:~/Desktop/VOiceInterface$ java test 

JVM-max:917504000
hadoop@slave2:~/Desktop/VOiceInterface$

 

おすすめ

転載: blog.csdn.net/wyqwilliam/article/details/91947550