I'll test this change:
diff --git a/src/share/classes/com/sun/tools/hat/internal/model/JavaStatic.java
b/src/share/classes/com/sun/tools/hat/internal/model/JavaStatic.java
--- a/src/share/classes/com/sun/tools/hat/internal/model/JavaStatic.java
+++ b/src/share/classes/com/sun/tools/hat/internal/model/JavaStatic.java
@@ -57,7 +57,10 @@ public class JavaStatic {
id = ((JavaObjectRef)value).getId();
}
value = value.dereference(snapshot, field);
- if (value.isHeapAllocated()) {
+ if (value.isHeapAllocated() &&
+ clazz.getLoader() == snapshot.getNullThing()) {
+ // static fields are only roots if they are in classes
+ // loaded by the root classloader.
JavaHeapObject ho = (JavaHeapObject) value;
String s = "Static reference from " + clazz.getName()
+ "." + field.getName();
Let me know if that seems right.
Unfortunately,
we haven't many jhat tests, did you have any small testcase scenarios?
The few tests for jhat are at jdk/tests/sun/tools/jhat, I can help craft one
if you give me something to start with.
-kto
Keith Randall wrote:
Here's a simpler patch that never makes Roots for these static fields in
the first place:
--- com/sun/tools/hat/internal/model/JavaStatic.java
***************
*** 57,64 ****
id = ((JavaObjectRef)value).getId();
}
value = value.dereference(snapshot, field);
! if (value.isHeapAllocated() &&
! clazz.getLoader() == snapshot.getNullThing()) { // static
fields are only roots if they are in classes loaded by the root classloader.
JavaHeapObject ho = (JavaHeapObject) value;
String s = "Static reference from " + clazz.getName()
+ "." + field.getName();
--- 57,63 ----
id = ((JavaObjectRef)value).getId();
}
value = value.dereference(snapshot, field);
! if (value.isHeapAllocated()) {
JavaHeapObject ho = (JavaHeapObject) value;
String s = "Static reference from " + clazz.getName()
+ "." + field.getName();
On Wed, Oct 7, 2009 at 1:49 AM, Alan Bateman <[email protected]
<mailto:[email protected]>> wrote:
A. Sundararajan wrote:
I agree. Static fields of classes loaded by non-bootstrap
loaders should not be part of root set.
PS. I am not sure if this is a bug with hat or with heap
dumpers (the hotspot built-in dumper and SA's dumper). I don't
remember how "roots" is filled. May be, these static fields
should not be flagged as roots?
-Sundar
At least for the built-in heap dumper, static fields aren't
generated as roots (instead it's system classes and temporary
placeholders in the dictionary that are generated to the dump as
"sticky classes", to use a HPROF term). So I suspect this is more
likely to be a jhat issue.
-Alan.