5.JVM三大性能调优参数:-Xms -Xmx -Xss
2016-05-31 11:37
381 查看
1.-Xss是对每个线程stack大小的调整。直接影响对方法的调用次数
测试结果:
测试代码:
package com.dt.spark.jvm.basics;
public class HelloStackOverFlow {
private static int counter;
public void count() {
System.out.println("the stack frame depth is : "+(++counter));
count();
}
public static void main(String[] args) {
//-verbose:gc -Xms10M -Xmx10M -Xss105k -XX:+PrintGCDetails
System.out.println("HelloStackOverFlow");
HelloStackOverFlow helloStackOverFlow = new HelloStackOverFlow();
try {
helloStackOverFlow.count();
} catch (Exception e) {
System.out.println("the stack frame depth is : "+(++counter));
e.printStackTrace();
throw e;
}
}
}
2.-Xms -Xmx 是对heap的调整
-Xms初始堆大小
-Xmx最大堆大小,一般情况下这两个值设为相同大小。因为如果不相同且内存不够用时会发生内存抖动现象,非常影响程序运行。
测试结果:
测试代码:
package com.dt.spark.jvm.basics;
import java.util.ArrayList;
import java.util.List;
class Person{ }
public class HelloHeapOutOfMemory {
public static void main(String[] args) {
System.out.println("HelloHeapOutOfMemory");
List<Person> persons = new ArrayList<Person>();
int counter = 0;
while(true){
persons.add(new Person());
System.out.println("Instance: " + (++counter));
}
}
}
测试结果:
测试代码:
package com.dt.spark.jvm.basics;
public class HelloStackOverFlow {
private static int counter;
public void count() {
System.out.println("the stack frame depth is : "+(++counter));
count();
}
public static void main(String[] args) {
//-verbose:gc -Xms10M -Xmx10M -Xss105k -XX:+PrintGCDetails
System.out.println("HelloStackOverFlow");
HelloStackOverFlow helloStackOverFlow = new HelloStackOverFlow();
try {
helloStackOverFlow.count();
} catch (Exception e) {
System.out.println("the stack frame depth is : "+(++counter));
e.printStackTrace();
throw e;
}
}
}
2.-Xms -Xmx 是对heap的调整
-Xms初始堆大小
-Xmx最大堆大小,一般情况下这两个值设为相同大小。因为如果不相同且内存不够用时会发生内存抖动现象,非常影响程序运行。
测试结果:
测试代码:
package com.dt.spark.jvm.basics;
import java.util.ArrayList;
import java.util.List;
class Person{ }
public class HelloHeapOutOfMemory {
public static void main(String[] args) {
System.out.println("HelloHeapOutOfMemory");
List<Person> persons = new ArrayList<Person>();
int counter = 0;
while(true){
persons.add(new Person());
System.out.println("Instance: " + (++counter));
}
}
}
相关文章推荐
- 看了《spring技术内幕》简单的图解总结下spring一些请求调用流程
- shell脚本的调试(trap、tee、shell选项)
- 加载数据之前的加载等待中效果
- day7—直播内容(元昊老师著)
- Python脚本性能分析
- jQuery页面加载初始化的3种方法
- Object类
- iOS使其支持侧滑返回
- android studio 使用快捷键
- 特性值长文本函数读取的用法(BAPI_CHARACT_GETLONGTEXT)
- 事件处理
- iOS开发 UICollectionView属性介绍
- tm结构
- 特殊IP地址(段)
- HVR日志分析简单应用
- 多维数组与交错数组的转换
- 遍历二叉树
- [置顶] 算法——选择、冒泡、插入
- Docker 常用命令
- Android 源码编译过程解释