This section provides a tutorial example on how to list object instance counts of all loaded classes in a Java heap dump file through the 'jhat' Web server.
Running "jhat" Web server on a heap dump file offers us a very good debugging tool.
You can get statistical counts of loaded classes and objects.
You can review object contents and references.
You can also run object queries to search for any specific information.
First, let's see how to get instance counts for all loaded classes.
1. Run a Web browser with http://localhost:7000. The heap dump first page shows up.
2. Click the link of "Show instance counts for all classes (including platform)".
The instance count page shows up:
65733 instances of class java.lang.String
362 instances of class java.lang.Class
330 instances of class [Ljava.lang.Object;
206 instances of class [C
66 instances of class [Ljava.lang.String;
58 instances of class java.util.Hashtable$Entry
50 instances of class [I
26 instances of class [B
19 instances of class java.util.Locale
19 instances of class java.util.concurrent.ConcurrentHashMap$HashEntry
17 instances of class [J
16 instances of class java.util.HashMap$Entry
16 instances of class java.util.concurrent.ConcurrentHashMap$Segment
16 instances of class java.util.concurrent.locks.ReentrantLock$NonfairSync
16 instances of class [D
16 instances of class [F
16 instances of class [Ljava.util.HashMap$Entry;
16 instances of class [Ljava.util.concurrent.ConcurrentHashMap$HashEntry;
14 instances of class java.lang.Object
14 instances of class java.util.HashMap
14 instances of class java.util.LinkedHashMap$Entry
12 instances of class java.io.ExpiringCache$Entry
11 instances of class java.net.URL
10 instances of class java.io.ObjectStreamField
....
The output shows that the highest count is the number of java.lang.String instances.
This is expected, because I created String arrays with 64*64 Strings in each array.