package com.dym.jvm;
public class T2 {
public static void main(String[] args) {
long maxMemory=Runtime.getRuntime().maxMemory(); //返回java 虚拟机试图使用的最大内存量
long totalMemory=Runtime.getRuntime().totalMemory(); // 返回java虚拟机中的内存总量
System.out.println("maxMemory"+maxMemory+"字节、"+(maxMemory/(double)1024/1024)+"MB");
System.out.println("totalMemory"+totalMemory+"字节、"+(totalMemory/(double)1024/1024)+"MB");
}
}
T2.java
package com.dym.jvm;
public class T2 {
public static void main(String[] args) {
long maxMemory=Runtime.getRuntime().maxMemory(); //返回java 虚拟机试图使用的最大内存量
long totalMemory=Runtime.getRuntime().totalMemory(); // 返回java虚拟机中的内存总量
System.out.println("-Xmx:maxMemory"+maxMemory+"字节、"+(maxMemory/(double)1024/1024)+"MB");
System.out.println("-Xms:totalMemory"+totalMemory+"字节、"+(totalMemory/(double)1024/1024)+"MB");
}
}
T3.java
package com.dym.jvm;
import java.util.Random;
public class T3 {
public static void main(String[] args) {
String str="fyreghrygh";
while(true){
str+=str+new Random().nextInt(88888888)+new Random().nextInt(99999999);
}
}
}
使用java代码查看计算机的cpu的核数package com.dym.jvm;public class T2 { public static void main(String[] args) { long maxMemory=Runtime.getRuntime().maxMemory(); //返回java 虚拟机试图使用的最大内存量 long totalMemory=Runtime.getRuntime().totalMemory(); //...