Skip to content

Debugging PermGen Space

September 9, 2010
tags:

use jstat for stats on perm gen space and gc utils.

jmap -permstat 2239

-XX:+TraceClassLoading or -XX:+TraceClassUnloading

OR use : Btrace just to get classes loaded info:

package com.sun.btrace.samples;

import static com.sun.btrace.BTraceUtils.*;
import com.sun.btrace.annotations.*;

/**
 * A simple BTrace program that prints stack trace
 * whenever a class is loaded by a user-defined
 * class loader. We insert a return point probe in
 * ClassLoader.defineClass method to detect successful
 * class load.
 */
@BTrace public class Classload {
   @OnMethod(
     clazz="java.lang.ClassLoader", 
     method="defineClass",
     location=@Location(Kind.RETURN)
   )   
   public static void defineclass(Class cl) {
       println(strcat("loaded ", name(cl)));
       jstack();
       println("==========================");
   }
}

Advertisements
No comments yet

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: