您的位置:首页 > 其它

内存溢出的一些个学习整理

2016-03-04 17:20 260 查看
tomcat/bin/catalina.sh 里面加句话

在以前的JAVA_OPTS 里面加

-verbose:gc -XX:+PrintGC -XX:+PrintGCDetails -XX:+PrintHeapAtGC -Xloggc:/web1gc.log 

我电脑里的是这个鬼:

JAVA_OPTS="$JAVA_OPTS -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=9988 -verbose:gc -XX:+PrintGC -XX:+PrintGCDetails -XX:+PrintHeapAtGC -Xloggc:/web1gc.log"  

后来  web1gc.log文件里面是这样的

{Heap before GC invocations=0 (full 0):

 def new generation   total 4800K, used 4288K [0x00000000eb400000, 0x00000000eb930000, 0x00000000f0750000)

  eden space 4288K, 100% used [0x00000000eb400000, 0x00000000eb830000, 0x00000000eb830000)

  from space 512K,   0% used [0x00000000eb830000, 0x00000000eb830000, 0x00000000eb8b0000)

  to   space 512K,   0% used [0x00000000eb8b0000, 0x00000000eb8b0000, 0x00000000eb930000)

 tenured generation   total 10624K, used 0K [0x00000000f0750000, 0x00000000f11b0000, 0x00000000fae00000)

   the space 10624K,   0% used [0x00000000f0750000, 0x00000000f0750000, 0x00000000f0750200, 0x00000000f11b0000)

 compacting perm gen  total 21248K, used 6562K [0x00000000fae00000, 0x00000000fc2c0000, 0x0000000100000000)

   the space 21248K,  30% used [0x00000000fae00000, 0x00000000fb468818, 0x00000000fb468a00, 0x00000000fc2c0000)

No shared spaces configured.

1.098: [GC1.098: [DefNew: 4288K->511K(4800K), 0.0111850 secs] 4288K->1542K(15424K), 0.0112660 secs] [Times: user=0.01 sys=0.00, real=0.01 secs] 

Heap after GC invocations=1 (full 0):

 def new generation   total 4800K, used 511K [0x00000000eb400000, 0x00000000eb930000, 0x00000000f0750000)

  eden space 4288K,   0% used [0x00000000eb400000, 0x00000000eb400000, 0x00000000eb830000)

  from space 512K,  99% used [0x00000000eb8b0000, 0x00000000eb92fff8, 0x00000000eb930000)

  to   space 512K,   0% used [0x00000000eb830000, 0x00000000eb830000, 0x00000000eb8b0000)

 tenured generation   total 10624K, used 1030K [0x00000000f0750000, 0x00000000f11b0000, 0x00000000fae00000)

   the space 10624K,   9% used [0x00000000f0750000, 0x00000000f0851a18, 0x00000000f0851c00, 0x00000000f11b0000)

 compacting perm gen  total 21248K, used 6562K [0x00000000fae00000, 0x00000000fc2c0000, 0x0000000100000000)

   the space 21248K,  30% used [0x00000000fae00000, 0x00000000fb468818, 0x00000000fb468a00, 0x00000000fc2c0000)

No shared spaces configured.

}   说实话 我也不知道他是什么鬼   无非大概就是内存越来越大了 你电脑有毛病吧  拜读的文章是这么说的

"泄露的结果是确定的,但是内存泄露点到底在哪根据日志也无法确切的查看清楚,通过在测试机器上的测试也很难找到哪块的业务操作才引起内存的增长。结果未能解决内存泄露问题 " 

未能解决内存泄露问题 !

未能解决内存泄露问题 !

未能解决内存泄露问题 !

所以并没有什么卵用 

jmap命令  不用下载什么 java jdk自带的命令 windows linux都能用

我的tomcat进程id是6212

jmap 6212        打印内存使用的摘要信息      摘要信息看不懂啊的说...真的是摘要么 不是天文么

jmap -heap 6212  查堆的摘要信息   看得模模糊糊的  used  free 的对比

jmap -histo:live 6212 和 jmap -histo 6212 >chen.txt 这两个都是输出一样的东西  一个输出在控制台 一个 写在文本里 一般用第二个,,因为类太多了,控制台显示篇幅有限

告诉你项目里面的这些类 实例化了多少次 ,,

以上内容- -我也不知道有什么用 

---------------------------------------------------------------------华丽的分割线--------------------------------------------------------------------------------

jmap -dump:format=b,file=gc.hprof 6212 生成了 一个gc.hprof 

eclipse 下个memory analysis tool    eclipse里面直接搜MAT 就找到了   

然后 file-> open heap dump  选择文件gc.hprof 一直确定

看到饼了 就看到成功的大门了 ...

.

.

.

.

.

.

.

.

.

.

.

.

.

没错,我看不懂 他的分析,哈哈,,,撞树中 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息