jmap-permstat-takes-long-time-and-hangs

http://stackoverflow.com/questions/25398588/jmap-permstat-takes-long-time-and-hangs


We started seeing 'java.lang.OutOfMemoryError: PermGen space'. In order to findout what is held in perm space, tried running

'/usr/j2sdk1.6.0_13/bin/jmap -permstat 20476 -J-mx1280m > /tmp/permstats20476.txt &'

This command is taking long time ..... in between it gave below exception:

finding class loader instances ..252829 intern Strings occupying 30781792 bytes.Finding object size using Printezis bits and skipping over...Finding object size using Printezis bits and skipping over...Finding object size using Printezis bits and skipping over...Finding object size using Printezis bits and skipping over...

done.computing per loader stat ..done.please wait.. computing liveness...................Exception in thread "Thread-1" java.lang.OutOfMemoryError: GC overhead limit exceeded at sun.jvm.hotspot.debugger.linux.LinuxDebuggerLocal.readBytesFromProcess0(Native Method) at sun.jvm.hotspot.debugger.linux.LinuxDebuggerLocal.access$1000(LinuxDebuggerLocal.java:51) at sun.jvm.hotspot.debugger.linux.LinuxDebuggerLocal$1ReadBytesFromProcessTask.doit(LinuxDebuggerLocal.java:558) at sun.jvm.hotspot.debugger.linux.LinuxDebuggerLocal$LinuxDebuggerLocalWorkerThread.run(LinuxDebuggerLocal.java:127)

but it is not completing ...

[svcmig2@app430 ~]$ uname -aLinux app430... 2.6.18-194.el5 #1 SMP Tue Mar 16 21:52:39 EDT 2010 x86_64 x86_64 x86_64 GNU/Linux

is there any other alternates to jmap ? so that i get the perm stats fast

share improve this question
 

is there any other alternates to jmap ? so that i get the perm stats fast

You can make one yourself! This is really easy with the aid of Serviceability Agent.

Here is an example for your case:

import sun.jvm.hotspot.memory.*;
import sun.jvm.hotspot.oops.*;
import sun.jvm.hotspot.runtime.*;
import sun.jvm.hotspot.tools.Tool;

public class PermTool extends Tool {

    @Override
    public void run() {
        // Show PermGen object histogram
        ObjectHistogram histo = new ObjectHistogram();
        VM.getVM().getObjectHeap().iteratePerm(histo);
        histo.print();

        // List all classes in PermGen with their ClassLoaders
        VM.getVM().getObjectHeap().iteratePerm(new DefaultHeapVisitor() {
            @Override
            public boolean doObj(Oop obj) {
                if (obj instanceof InstanceKlass) {
                    obj.printValue();
                    Oop loader = ((InstanceKlass) obj).getClassLoader();
                    if (loader == null) {
                        System.out.println(" -- loaded by Bootstrap ClassLoader");
                    } else {
                        System.out.print(" -- loaded by ");
                        loader.printValue();
                        System.out.println();
                    }
                }
                return false;
            }
        });
    }

    public static void main(String[] args) {
        new PermTool().start(args);
    }
}

Just compile and run it using the same JDK as your target process.
Make sure jdk/lib/sa-jdi.jar is on the CLASSPATH.

share improve this answer
 
 
Thanks Apangin. This gives big picture of Perm space in short time. But it would be nice to analyze, if we can get detailed breakup of ConstMethodKlass,MethodKlass,ConstantPoolKlass,InstanceKlassKlass,ConstantPoolCa‌​cheKlass. Not sure if it is possible ? –  Bhaskar Na Aug 22 '14 at 6:18
 
@BhaskarNa Yes, it is possible. Replace ObjectHistogram with your custom HeapIterator and do whatever you want. What whould you like to see in the "detailed breakup"? –  apangin Aug 22 '14 at 9:18
 
like which class took how much space for ex.,i am interested in what contributed to make ConstMethodClass to become 40m 1: 288821 44468976 * ConstMethodKlass 2: 288821 39291944 * MethodKlass 3: 30791 38145216 * ConstantPoolKlass 4: 30791 33647264 * InstanceKlassKlass 5: 27913 22935072 * ConstantPoolCacheKlass –  Bhaskar Na Aug 22 '14 at 9:29
 
@BhaskarNa OK, I edited the answer so that the tool now prints all classes in PermGen. Looks like your application has loaded nearly 30K classes! There is either a ClassLoader leak or you use CMS GC and have not set -XX:+CMSClassUnloadingEnabled JVM options. –  apangin Aug 22 '14 at 22:09
 
</br> Now i do see all the classes that contributes to 30788 InstanceKlass but I don't see similar break up for others like ConstMethodKlass, MethodKlass, etc., Let me check for these types and see if they gets printed... </br> 1: 288148 44352968 * ConstMethodKlass 2: 288148 39200416 * MethodKlass 3: 30788 38125192 * ConstantPoolKlass 4: 30788 33637208 * InstanceKlassKlass 5: 27956 22936576 * ConstantPoolCacheKlass 6: 15144 8258912 * MethodDataKlass –  Bhaskar Na Aug 23 '14 at 8:58

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值