Getting value from a NIO direct buffer

Questions about YourKit Java Profiler
Locked
pavol.zibrita
Posts: 6
Joined: Thu Nov 22, 2007 8:43 am

Getting value from a NIO direct buffer

Post by pavol.zibrita »

Hi,

Is it possible in some way to get a value from a java.nio.DirectByteBuffer if I have address and offset that I would like to look at, in memory snapshot? Or hprof snapshot? Or in some other way?

Generally what Unsafe.getInt(address) is doing. Is in any way possible to get the value using the snapshot as well?

Regards,
Pavol
Anton Katilin
Posts: 6172
Joined: Wed Aug 11, 2004 8:37 am

Re: Getting value from a NIO direct buffer

Post by Anton Katilin »

Hello Pavol,

Unfortunately, native memory content is not available in a memory snapshot, neither .snapshot nor .hprof.

Best regards,
Anton
pavol.zibrita
Posts: 6
Joined: Thu Nov 22, 2007 8:43 am

Re: Getting value from a NIO direct buffer

Post by pavol.zibrita »

Any chance of adding such feature to the agent and yourkit? However, not sure how much it would/could be used.

In mean time, I was able to get the value based on the memory address I found in memory snapshot and then using dd to get the value from the process memory as described here:

https://unix.stackexchange.com/question ... ng-command
pavol.zibrita
Posts: 6
Joined: Thu Nov 22, 2007 8:43 am

Re: Getting value from a NIO direct buffer

Post by pavol.zibrita »

It was something like this:

Code: Select all

 
sudo dd bs=1 skip="$((0x7F8FB21BA011))" count=4 if="/proc/4341/mem" | od -An -vtd4
dd: ‘/proc/4341/mem’: cannot skip to specified offset
4+0 records in
4+0 records out
4 bytes (4 B) copied, 5.9129e-05 s, 67.6 kB/s
          -1
I just needed to confirm the value on the address is -1. If it wouldn't be, I would have to investigate the bug that was happening in some other direction.
Anton Katilin
Posts: 6172
Joined: Wed Aug 11, 2004 8:37 am

Re: Getting value from a NIO direct buffer

Post by Anton Katilin »

Hi Pavol,
Any chance of adding such feature to the agent and yourkit? However, not sure how much it would/could be used.
We have added corresponding feature request.
I was able to get the value based on the memory address I found in memory snapshot
Interesting approach, thank you for sharing. Unfortunately it works only while the process is still alive and is not applicable after it has terminated.

Best regards,
Anton
Locked