Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 340349

Summary: With IBM PHD, gc root not calculated if object points to itself
Product: [Tools] MAT Reporter: Brian Peacock <brian_peacock>
Component: CoreAssignee: Project Inbox <mat.core-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: andrew_johnson
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
Patch to stop obj pointing to itself not being gcroot elligible andrew_johnson: iplog+

Description Brian Peacock CLA 2011-03-17 13:05:51 EDT
Build Identifier: 

The code in the DTFJIndexBuilder that calculates the gcroots when using a PHD (heapdump which doesn't contain root information) it assumes that if nothing points to an object it is a gc root. However, the current code assumes that if the object points to itself it is pointed to by something and thus cannot be a gc root.

To fix it a simple "if points to itself don't assume this is not a root' needs to be added to addRefs()

Reproducible: Always
Comment 1 Brian Peacock CLA 2011-03-17 13:10:09 EDT
Created attachment 191445 [details]
Patch to stop obj pointing to itself not being gcroot elligible
Comment 2 Andrew Johnson CLA 2011-03-21 05:50:43 EDT
Thanks - that's a useful point. It makes no difference to the two test case dumps
/org.eclipse.mat.tests/dumps/heapdump.20100112.141124.11580.0002.phd
/org.eclipse.mat.tests/dumps/heapdump.20100209.165721.4484.phd
but might be useful for other dumps.

For the record, please could you confirm for the patch:
1.that you wrote 100% of the code
2.that you are authorized to contribute it
3.that is is submitted under the EPL.
This is needed so we can use the patch.
Comment 3 Brian Peacock CLA 2011-03-28 04:08:26 EDT
> For the record, please could you confirm for the patch:
> 1.that you wrote 100% of the code
Yes
> 2.that you are authorized to contribute it
Yes
> 3.that is is submitted under the EPL.
Yes
Comment 4 Andrew Johnson CLA 2011-03-28 10:03:16 EDT
I'll also make the corresponding change to GarbageCleaner.java which also calculates extra GC roots for otherwise unreachable objects.
Comment 5 Andrew Johnson CLA 2011-04-04 11:48:42 EDT
I've also improved the selection of extra GC roots in GarbageCleaner for keep_unreachable_objects.