Error attaching to process: sun.jvm.hotspot.debugger.DebuggerException: Can’t attach to the process [ solved ]


I was in the process of getting the much awaited heap dump using jmap, from an ailing java process and booom !! This happens !!

Error attaching to process: sun.jvm.hotspot.debugger.DebuggerException: Can't attach to the process

Well, there are two things here that needs to be taken care off.

  1. The jmap process and the java process ( of whose, the heap dump is being taken ) should be running in the same user id.
  2. There is a linux ptrace bug which will prevent jmap from attaching to the java process. To resolve this, punch in the following command before you execute the jmap heapdump command.
echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope

Now go ahead and execute the heapdump command using jmap.

jmap -heap:format=b <process-id>

and voila !!…You are done !! 🙂 🙂

 

Advertisements

5 comments

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s