I don't think there's any way to do with Java's core APIs - unless you consider the Java Platform Debugger Architecture to be part of the "core". The JVMTI has IterateOverInstancesOfClass, but you need to write C code to access it. the JDI is more Java-friendly, but I don't see a way to request events for creation and destruction of objects. Maybe I'm missing something.
Anyway, using existing profilers and IDEs is by far the easiest way to do this. JVMTI gives you a way to custom-make your own tool which can do just what you want. But if you want a solution that just uses the standard Java libraries, I don't think there is one.
"I'm not back." - Bill Harding, Twister
Joined: Nov 29, 2005
Originally posted by Jim Yingst: but I don't see a way to request events for creation and destruction of objects. Maybe I'm missing something.
Thanks Jim and John.
I do not need events for creation and destruction of objects.I just want the number of instances of any given class in the heap at that point of time.
I will evaluate the stuffs mentioned by you.I am sure that those will be of use for my issue.
Thanks once again.
subject: Finding number of String objects in the heap.