import java.math.BigDecimal;
import com.yourkit.api.Controller;
public class MemoryTest {
public static void main (String[] args) throws Exception {
MT0 mt0 = new MT0 ();
MT0 mt1 = new MT1 (); // There was a mistake on this line
new Controller ().captureMemorySnapshot ("MemoryTest", false);
}
}
class MT0 {
Object ref1 = new Object ();
Object ref2 = "Hello";
Object ref3 = Integer.valueOf (10000);
BigDecimal bd = new BigDecimal (0);
int anInt;
}
class MT1 extends MT0 {
public Object o1;
}
You're talking about "Class tree" view, I was talking about each MT* object in particular shown in "Outgoing references".
The separation by classes in the "Class tree" is done without objects of subclasses. So line MT0 means object of exactly MT0, and MT1 - exactly MT1. Thus field ref2 of MT0 is considered different from field ref2 of MT1. None of them "alone" retain the String, because they both hold it.
This shows again that per-field values in Class tree are confusing... As I've said earlier, we're considering to change it.