Friday, January 10, 2014

How to avoid jmap error - Error attaching to process: sun.jvm.hotspot.debugger.DebuggerException: Can't attach to the process

When you need to attach process to jmap you might get following error here i have described how we can avoid that.

Run fllowing to get process ID
 :jps
3252 Bootstrap
3513 Jps

Then run following to execute jmap
:jmap -heap:format=b 3252
Attaching to process ID 3252, please wait...
Error attaching to process: sun.jvm.hotspot.debugger.DebuggerException: Can't attach to the process

Then to avoid error run following
:echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope

Then run again above command
:jmap -heap:format=b 3252
Attaching to process ID 3252, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 17.0-b16

using thread-local object allocation.
Parallel GC with 4 thread(s)

Heap Configuration:
   MinHeapFreeRatio = 40
   MaxHeapFreeRatio = 70
   MaxHeapSize      = 1073741824 (1024.0MB)
   NewSize          = 1310720 (1.25MB)
   MaxNewSize       = 17592186044415 MB
   OldSize          = 5439488 (5.1875MB)
   NewRatio         = 2
   SurvivorRatio    = 8
   PermSize         = 21757952 (20.75MB)
   MaxPermSize      = 268435456 (256.0MB)

Heap Usage:
PS Young Generation
Eden Space:
   capacity = 263847936 (251.625MB)
   used     = 226730648 (216.2271957397461MB)
   free     = 37117288 (35.397804260253906MB)
   85.93231822742021% used
From Space:
   capacity = 36372480 (34.6875MB)
   used     = 16924568 (16.140525817871094MB)
   free     = 19447912 (18.546974182128906MB)
   46.53124560106982% used
To Space:
   capacity = 40763392 (38.875MB)
   used     = 0 (0.0MB)
   free     = 40763392 (38.875MB)
   0.0% used
PS Old Generation
   capacity = 333053952 (317.625MB)
   used     = 179019752 (170.7265396118164MB)
   free     = 154034200 (146.8984603881836MB)
   53.75097665858053% used
PS Perm Generation
   capacity = 151519232 (144.5MB)
   used     = 93595192 (89.25933074951172MB)
   free     = 57924040 (55.24066925048828MB)
   61.771163148451016% used

You will see correct output

1 comment:

  1. Hi Sanjeewa,

    I was facing same issue, but command jmap -heap:format=b 3252 created a file heap.bin which is not human readable.
    Can you help ?

    ReplyDelete