Listing Instance Counts of All Classes

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$Entry 
11 instances of class 
10 instances of class 

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.

Last update: 2015.

Table of Contents

 About This Book

 Java Tools Terminology

 Installing Java 8 on Windows

 'javac' - The Java Program Compiler

 'java' - The Java Program Launcher

 'jdb' - The Java Debugger

 'jconsole' - Java Monitoring and Management Console

 'jstat' - JVM Statistics Monitoring Tool

JVM Troubleshooting Tools

 JVM Troubleshooting Tools in JDK 1.5

 'jinfo' - VM Option Value Checker

 Changing HotSpot VM Option using 'jinfo'

 'jstack' - Stack Tracer to Generate Thread Dump

 What Is a Thread Dump?

 Java Thread Deadlock Demo Program

 Detecting Java Thread Deadlocks with 'jstack'

 'jmap' - JVM Heap Dump Tool

 Printing Histogram of Java Object Heap

 Generating Heap Dump File with 'jmap'

 'jhat' - Java Heap Analysis Tool

 Starting 'jhat' Web Server on a Heap Dump File

Listing Instance Counts of All Classes

 Browsing Object Instance Values

 Object Query Language (OQL)

 Searching for Instances with OQL Statements

 jvisualvm (Java VisualVM) - JVM Visual Tool

 'jar' - The JAR File Tool

 'javap' - The Java Class File Disassembler

 'keytool' - Public Key Certificate Tool

 'native2ascii' - Native-to-ASCII Encoding Converter

 Outdated Tutorials


 PDF Printing Version