Eclipse配置jvm参数

时间:2021-12-07 17:20:34

Eclipse配置jvm参数

 

 

 

Eclipse配置jvm参数

 

 

配置参数:-Xms34m -Xmx234m

内存初始化大小,最小和最大值;

 

测试代码:

public class JVMDemoTest {

public static void main(String[] args) {
System.out.println(
"memory info : " + toMemoryInfo());

}

static String toMemoryInfo() {

Runtime runtime
= Runtime.getRuntime();
int freeMemory = (int) (runtime.freeMemory() / 1024 / 1024);
int totalMemory = (int) (runtime.totalMemory() / 1024 / 1024);
return freeMemory + "M/" + totalMemory + "M(free/total)";
}

}

 

配置参数后运行结果:

memory info : 32M/34M(free/total)

 

默认运行结果:

memory info : 254M/256M(free/total)