1 Reply Latest reply on Oct 7, 2011 1:52 PM by 891886

    Lost objects when iterating over the heap


      I am writing a profiler to track thread locality information for "all" objects. In the object tag, I am storing a pointer to a structure that holds some information about the objects and threads accessing it.

      What I want to do is, when a Java program terminates, I want to iterate over all objects, to store locality information somewhere, I also do so whenever an object is freed, I record its information then delete the structure associated to it. I expected that this, plus a heap iteration after the end of thread "DestroyJavaVM" will guarantee that I go over all objects I tagged before, but this is not the case.

      for example, one application (Lucene Search Library), created 4888867 objects, but I could only collect 4811717 objects at the end of the program (I am losing 77150 objects!), relying on object free and iterate over heap functions. I am filtering out untagged objects, but this should not be an issue.

      What is wrong with what I'm doing? if those 77150 were not freed (if they were, I would record their information at the object free function), then I think I should be able to read them at the end of execution from the heap, but this is not the case. It seems like they just vanished.

      Before, I was tracking objects in a different way, I had a map from object ID (used as its tag) to its information structure, but I wanted to get rid of the memory and map computations overhead, so I changed to the approach I described earlier.

      I appreciate any help or hints.