随笔-java进行内存分析

来源:互联网 发布:linux和windows哪个快 编辑:程序博客网 时间:2024/05/21 20:25
n=$1if [ -z $n  ];then    n=10fipid=`jps -lv|grep Server|awk '{print $1}'`jmap -histo:live $pid >jmap1.txtsleep 10jmap -histo:live $pid >jmap2.txtcat jmap1.txt|sed 's/\[/\\[/g' >fjmap1.txtcat jmap2.txt|sed 's/\[/\\[/g' >fjmap2.txtobj_l=`cat fjmap2.txt |sed -n '4,$p'|awk {'print $4 '}|head -n $n`objnum_l=`cat fjmap2.txt |sed -n '4,$p'|awk {'print $3 '}|head -n $n`objcount_l=`cat fjmap2.txt |sed -n '4,$p'|awk {'print $2 '}|head -n $n`#echo $obj_li=1for obj in $obj_ldoecho No.$i:target=`echo $obj|awk {'print $1'}`echo $targetnum2=`echo $objnum_l|cut -d " " -f $i`num1=`cat fjmap1.txt |sed -n '4,$p'|grep "$target"|head -n 1|awk {'print $3'}`count2=`echo $objcount_l|cut -d " " -f $i`count1=`cat fjmap1.txt |sed -n '4,$p'|grep "$target"|head -n 1|awk {'print $2'}`if [ -z $num2 ];then        num2=0fi        if [ -z $num1 ];then                num1=0        fiif [ -z $count2 ];then                count2=0        fi        if [ -z $count1 ];then                count1=0        finum=`expr $num2 - $num1`echo "charge_heap:$num"count=`expr $count2 - $count1`        echo "charge_count:$count"((i=i+1))done#echo `cat jmap1.txt |grep javax.xml.namespace.QName|head -n 1|awk {'print $3'}`

建议可以在java出现fgc的时候调用此脚本

1 0
原创粉丝点击