> On 30 mars 2016, at 09:40, Bacchu, Anjan <anjan.bac...@hpe.com> wrote: > > Hi Staffan, > > I just now saw the presentation slides at > http://www.slideshare.net/stalar/diagnosing-your-application-on-the-jvm > <http://www.slideshare.net/stalar/diagnosing-your-application-on-the-jvm>. > > On Slide 16 of the presentation, you show the details of the “HotSpot Dynamic > Attach Mechanism” for Windows. > > 1) You talk about Remote process injecting code into the JVM using > combination of VirtualAllocEx and > 2) WriteProcessMemory. Further it goes ahead and creates a Remote thread in > the JVM to call above code. > > > Do you have some sample code which does this, to say, dump the heap ?
If you want to dump the heap, take a look at “jcmd <pid> GC.heap_dump”: ---------- Generate a HPROF format dump of the Java heap. Impact: High: Depends on Java heap size and content. Request a full GC unless the '-all' option is specified. Permission: java.lang.management.ManagementPermission(monitor) Syntax : GC.heap_dump [options] <filename> Arguments: filename : Name of the dump file (STRING, no default value) Options: (options must be specified using the <key> or <key>=<value> syntax) -all : [optional] Dump all objects, including unreachable objects (BOOLEAN, false) ---------- You can also use “jmap -dump <pid>. > > I used to develop windows application long ago and just from the slide #16 > andhttp://openjdk.java.net/groups/hotspot/docs/Serviceability.html#battach > <http://openjdk.java.net/groups/hotspot/docs/Serviceability.html#battach>, > I’m unable to proceed further. The source code is in the VirtualMachineImpl.c file for windows: http://hg.openjdk.java.net/jdk9/jdk9/jdk/file/1565a0efe6f0/src/jdk.attach/windows/native/libattach/VirtualMachineImpl.c <http://hg.openjdk.java.net/jdk9/jdk9/jdk/file/1565a0efe6f0/src/jdk.attach/windows/native/libattach/VirtualMachineImpl.c> > > All help will be useful. > > Thank you very much, > > BR, > ~A