How can I find the number of live objects on the heap in Java program?
Use jvisualvm, and do a memory sample. It will show the number of classes and instances: