views:

23

answers:

1

I am writing a small code to detect number of objects left behind after certain actions in our tool. This uses FollowReferences() JVMTI-API. This counts instances reachable by all paths. How can I skip paths that included weak/soft/phantom reference?

(IterateThroughHeap counts all objects at the moment, so the number is not fully reliable)

Thanks, Jayan

A: 

Solution (for now) is to use FindClass for "java/land/ref/Reference" and then tag this as to be skipped. In the callback for FollowReference, skip the iteration when class is marked to be skipped. (real solution could be to use hprof code, shipped with Sun JDK)

Jayan