Fully featured low overhead profiler for Java EE and Java SE platforms.
Easy to use performance and memory .NET profiler for Windows and Linux.
Performance monitoring and profiling of Jenkins, Bamboo, TeamCity, Gradle, Maven, Ant and JUnit.

Getting value from a NIO direct buffer

Moderators: Vladimir Kondratyev, Anton Katilin

Getting value from a NIO direct buffer

Postby pavol.zibrita » Thu Apr 08, 2021 7:32 am

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
pavol.zibrita
 
Posts: 6
Joined: Thu Nov 22, 2007 8:43 am

Re: Getting value from a NIO direct buffer

Postby Anton Katilin » Thu Apr 08, 2021 9:52 am

Hello Pavol,

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

Best regards,
Anton
Anton Katilin
 
Posts: 6025
Joined: Wed Aug 11, 2004 8:37 am

Re: Getting value from a NIO direct buffer

Postby pavol.zibrita » Fri Apr 09, 2021 1:45 am

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

Postby pavol.zibrita » Fri Apr 09, 2021 2:06 am

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.
pavol.zibrita
 
Posts: 6
Joined: Thu Nov 22, 2007 8:43 am

Re: Getting value from a NIO direct buffer

Postby Anton Katilin » Fri Apr 09, 2021 8:57 am

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


Return to Java Profiler

Who is online

Users browsing this forum: No registered users and 1 guest

cron

YourKit uses cookies and other tracking technologies to improve your browsing experience on our website, to show you personalized content and targeted ads, to analyze our website traffic, and to understand where our visitors are coming from.

By browsing our website, you consent to our use of cookies and other tracking technologies in accordance with the Privacy Policy.