How can I find the number of live objects on the heap in Java program?
There is a hack you can try:
see this (old) article for a sample.
Probably there are better ways to do it using JPDA or JMX, but I've not found how...