« December 2009
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
  
       
Today
XML

Blog::Navigation

GetJava Download Button
Get the Source
Personal Blog

Blog::Referers

Today's Page Hits: 124

Powered by Roller Weblogger.
« Mixed mode stack... | Main | Yes, there is also... »
20060217 Friday February 17, 2006

4 ways to view Java heap histogram with Mustang

With Mustang (Java SE 6), there are atleast 4 ways to get histogram of Java heap:

  1. Using jmap
    
        jmap -histo <pid-of-java-process>
    
    
  2. Using -XX:+PrintClassHistogram option when starting the java application. With this option, whenever SIGQUIT signal is sent (pressing Ctrl-\ on Unix, Ctrl-Break on Windows), heap histogram is printed.
  3. Using jmap tool to dump heap dump and viewing the same using jhat
    
        jmap -dump:format=b,file=heap.bin <pid-of-java-process>
        jhat heap.bin
    
    
    When jhat is started, visit the URL "http://localhost:7000/" and click on "Show heap histogram" link to view the histogram.
  4. Using DTrace with Mustang. The following D-script accumulates count and total size in aggregates -- which can be printed on END probe. This script uses object-alloc probe. More details on Mustang built-in DTrace probes can be found in Keith's blog
    
        hotspot$1:::object-alloc {
            self->str_ptr = (char*) copyin(arg1, arg2+1);
            self->str_ptr[arg2] = '\0';
            self->classname = (string) self->str_ptr;
            @allocs_count[self->classname] = count();
            @allocs_size[self->classname] = sum(arg3);
        }
    



( Feb 17 2006, 03:39:07 PM IST ) Permalink Comments [1] del.icio.us | furl | simpy | slashdot | technorati | digg

Comments:

Or maybe 5 if you include the demo jvmti agent in the demo/jvmti/heapViewer/lib directory :-)

Posted by Alan on February 17, 2006 at 05:26 PM IST #

Post a Comment:

Comments are closed for this entry.
Copyright (C) 2005, A. Sundararajan's Weblog