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);
        }
    
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 09:26 AM IST #

Post a Comment:
Comments are closed for this entry.
About

sundararajan

Search

Archives
« April 2014
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
   
       
Today
Bookmarks
Links

No bookmarks in folder

Blogroll

No bookmarks in folder

News

No bookmarks in folder