Some references aren't shown? (4.0.14)

Questions about YourKit Java Profiler
Post Reply
Gibson
Posts: 181
Joined: Mon Apr 11, 2005 10:38 am

Some references aren't shown? (4.0.14)

Post by Gibson »

Continuing the series of "testing my understanding of the memory view" ;)

Code: Select all

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 MT0 ();

		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;
}
I would expect to see
MT0
- ref11 Object
- ref2 1 Object
- ref3 1 Object
- bd 1 Object
MT1
- ref11 Object
- ref2 1 Object
- ref3 1 Object
- bd 1 Object

But instead I have
MT0
- ref11 Object
- ref3 1 Object
- bd 1 Object
MT1
- ref11 Object
- ref3 1 Object
- bd 1 Object

What happened to ref2?
Gibson
Posts: 181
Joined: Mon Apr 11, 2005 10:38 am

Post by Gibson »

Oops, sorry, I posted the wrong code above. It should read:

Code: Select all

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;
}
Anton Katilin
Posts: 6172
Joined: Wed Aug 11, 2004 8:37 am

Post by Anton Katilin »

I've just tried your example (the latest code that you have sent).

It's all OK for me - ref2 field correctly points to "Hello" string.

I'm running Java 5.0 u4 on Windows, JVMTI.
Gibson
Posts: 181
Joined: Mon Apr 11, 2005 10:38 am

Post by Gibson »

This is completely reproducible for me, I'm running

Code: Select all

[rgibson@incredible ~]$ uname -a
Linux incredible.fr.nexgenfs.com 2.6.11-1.27_FC3smp #1 SMP Tue May 17 20:43:11 EDT 2005 i686 i686 i386 GNU/Linux
[rgibson@incredible ~]$/home/JavaLibs/jdk1.5.0_04/bin/java -Xmx256m -ea  -agentlib:yjpagent  tests.misc.MemoryTest
[YourKit Java Profiler 4.0.14] Using JVMTI
[YourKit Java Profiler 4.0.14] Listening on port 35525...
[YourKit Java Profiler 4.0.14] Request from 127.0.0.1: Memory snapshot is saved to /home/rgibson/MemoryTest(1).memory
Is there somewhere I can upload my memory snapshot to?
Anton Katilin
Posts: 6172
Joined: Wed Aug 11, 2004 8:37 am

Post by Anton Katilin »

Yes, could you please upload it to:

FTP host: 194.24.241.147
username: ftp
password: no password
Gibson
Posts: 181
Joined: Mon Apr 11, 2005 10:38 am

Post by Gibson »

Host doesn't seem to be available :(
Vladimir Kondratyev
Posts: 1624
Joined: Tue Aug 10, 2004 7:52 pm

Post by Vladimir Kondratyev »

ftp://194.24.241.196 is a right IP address
Anton Katilin
Posts: 6172
Joined: Wed Aug 11, 2004 8:37 am

Post by Anton Katilin »

I finally understood what the problem is.

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.
Anton Katilin
Posts: 6172
Joined: Wed Aug 11, 2004 8:37 am

Post by Anton Katilin »

P.S: Thus there's no need to upload the snapshot :)
Gibson
Posts: 181
Joined: Mon Apr 11, 2005 10:38 am

Post by Gibson »

OK, I understand, thanks. But I still have a question about what the "Objects" column actually displays, see my other post http://forums.yourkit.com/viewtopic.php?t=316[/url]
Anton Katilin
Posts: 6172
Joined: Wed Aug 11, 2004 8:37 am

Post by Anton Katilin »

OK, I'm answering in that thread.
Post Reply