The heap iteration functions don't create objects in the java heap. I assume the issue you are seeing is that some random mutator in the application allocates some objects in the window between two iterations. If that is your issue then it might be worth seeing if you can structure the agent so that it dumps the heap references in one iteration rather than requiring multiple iterations. If you pre-tag all classes then you may have sufficient context to do this in one call to IterateOverReachableObjects. There are many improvements in this area in Mustang (Java SE 6) with the new FollowReferences function.
Hi,
a little improvement I got by putting the object tagging and reference processing in one iterateOverReachableObjects. But to identify garbage there is no other way (I think) as to do a second itearation by iterateOverHeap(untagged).
But if those function do not create garbage then the issue is cleared anyway.
Thanks, Robert