Coder Social home page Coder Social logo

jattach's Introduction

jattach

JVM Dynamic Attach utility

The utility to send commands to a JVM process via Dynamic Attach mechanism.

All-in-one jmap + jstack + jcmd + jinfo functionality in a single tiny program.
No installed JDK required, works with just JRE. Supports Linux containers.

This is the lightweight native version of HotSpot Attach API
https://docs.oracle.com/javase/8/docs/jdk/api/attach/spec/

Supported commands:

  • load : load agent library
  • properties : print system properties
  • agentProperties : print agent properties
  • datadump : show heap and thread summary
  • threaddump : dump all stack traces (like jstack)
  • dumpheap : dump heap (like jmap)
  • inspectheap : heap histogram (like jmap -histo)
  • setflag : modify manageable VM flag
  • printflag : print VM flag
  • jcmd : execute jcmd command

Download

Binaries are available on the Releases page.

On some platforms, you can also install jattach with a package manager.

Examples

Load native agent

$ jattach <pid> load <.so-path> { true | false } [ options ]

Where true means that the path is absolute, false -- the path is relative.

options are passed to the agent.

Load Java agent

Java agents are loaded by the special built-in native agent named instrument, which takes .jar path and its arguments as a single options string.

$ jattach <pid> load instrument false "javaagent.jar=arguments"

List available jcmd commands

$ jattach <pid> jcmd help -all

Installation

Debian, Ubuntu

On Debian and Ubuntu, you can install jattach from the official repository:

# apt install jattach

Alpine Linux

On Alpine Linux, you can install jattach package from the edge/community repository:

# apk add --no-cache jattach --repository http://dl-cdn.alpinelinux.org/alpine/edge/community/

Archlinux

jattach package can be installed from AUR using one of AUR helpers, e.g., yay:

# yay -S jattach

FreeBSD

On FreeBSD, you can use the following command to install jattach:

# pkg install jattach

jattach's People

Contributors

andreaskl avatar apangin avatar goldshtn avatar hwesselmann avatar incubos avatar jchipmunk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jattach's Issues

No dump file specified

Hi,

I am trying to capture heap dump from the process running inside a docker container but getting a "No dump file specified" error message.

I am executing the below command from the host and passing the process id from the host PID namespace.

sudo ./jattach <PID> dumpheap > heapdump.bin

How to build for 64 bit JVM.

I built the windows code but when i run the tool i get the following error.
"Cannot attach 64-bit process to 32-bit JVM"

What can be done to solve it?

Unable to take threaddump during the issue

Hi,

I am using jattach inside docker container, I am able to take thread dump when my application or JVM is running fine, but when the JVM has any issue like threads choked or memory leak, I mean to say unresponsive. jattach is giving following error:

Could not start attach mechanism: No such file or directory

How to pass agentArgs when attaching?

Using the -javaagent I can pass the agentArgs as:

-javaagent:agent.jar='my agent jars'

Any suggestion how can this be done when attaching?

Thanks in advance,
Ivan

Error "Not a HPROF heap dump"

when i try to dump heap for a living jvm,used follow command.

jattach 13174 dumpheap mydump.hprof

I'm used to using MemoryAnalyzer(mat,latest version) to analyze the dump heap.

but actually,the mat cannot open mydump.hprof,just reported a error:

Error opening heap dump 'mydump.hprof'. Check the error log for further details.
Error opening heap dump 'mydump.hprof'. Check the error log for further details.
Not a HPROF heap dump (java.io.IOException)
Not a HPROF heap dump

sorry for my pool English,please help and fix this bug.thanks.

Run jattach without sudo

Hi,

I have embedded jattach into my go script. When I run my go script from host to capture GC log, thread dump, and heap dump from the java application running inside the Docker container I get Failed to change credentials to match the target process: Operation not permitted error message. But if I run my go script with sudo it works fine.

I am using a service account. Can you help me with figuring out what priviledges are required to access the monitoring information rather than using sudo?

Thanks :)

Hanging forever

./jattach 2233 properties

Connected to remote JVM
Response code =

unable to build in cygwin x86 using GNU make 4.1

Tried building on windows 7 Enterprise using cygwin with GNU make 4.1. Got below errors

c:\work\java\heapDump\jattach-master>make
mkdir -p build
gcc -O2 -o build/jattach src/jattach.c
make: gcc: Command not found
Makefile:4: recipe for target 'build/jattach' failed
make: *** [build/jattach] Error 127

c:\work\java\heapDump\jattach-master>make --version
GNU Make 4.1
Built for i686-pc-cygwin
Copyright (C) 1988-2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

c:\work\java\heapDump\jattach-master>

Statistic on Memory Heap Usage

First of all, thank you for creating this useful tool! It's simple and yet powerful.

I'm trying to figure out how to get USED heap RAM of JVM which is running inside a docker container. If java process is not running in a docker container than we can

start="ManagementAgent.start jmxremote.port=$port jmxremote.rmi.port=$port jmxremote.ssl=false jmxremote.authenticate=false"
jattach $pid jcmd "$start"

and then connect via JMX with the following code

JMXConnector c = JMXConnectorFactory.newJMXConnector(createConnectionURL(host, port), null);
c.connect();
MBeanServerConnection mbsc = c.getMBeanServerConnection();
MemoryMXBean mem = ManagementFactory.getPlatformMXBean(mbsc, MemoryMXBean.class);
MemoryUsage heap = mem.getHeapMemoryUsage();
MemoryUsage nonHeap = mem.getNonHeapMemoryUsage();

However, with docker it does not work as we have to open jmx port at the start of the container which is not possible in our case. We run inspection / memory usage analysis on the host machine and can't stop/start containers for this operation.

Maybe datadump command can provide a summary about used heap memory, but it seems like this command does not provide any information...

jattach <pid> datadump
Connected to remote JVM
Response code = 0 

What can you advise? Is there any way to get JMX information via jattach without the need to open JMX port in a docker container?

Thanks

Could not start attach mechanism: No such file or directory

I am running a java application inside the container and jattach on the host. The java process id on the host is 20557. When I execute the jattach to capture threaddump and heapdump from the host. I get the below errors -

Thread dump - Could not start attach mechanism: No such file or directory

Heap Dump -

com.sun.tools.attach.AttachNotSupportedException: Unable to open socket file /proc/20557/root/tmp/.java_pid20557: target process 20557 doesn't respond within 10500ms or HotSpot VM not loaded at jdk.attach/sun.tools.attach.VirtualMachineImpl.<init>(VirtualMachineImpl.java:100) at jdk.attach/sun.tools.attach.AttachProviderImpl.attachVirtualMachine(AttachProviderImpl.java:58) at jdk.attach/com.sun.tools.attach.VirtualMachine.attach(VirtualMachine.java:207) at jdk.jcmd/sun.tools.jcmd.JCmd.executeCommandForPid(JCmd.java:114) at jdk.jcmd/sun.tools.jcmd.JCmd.main(JCmd.java:98)

I have seen the troubleshooting section in this link

  1. Attach socket file .java_pidNNN is not present in /tmp directory on the host. when I execute lsof -p PID | grep java_pid it doesn't return any output.
  2. I have not started JVM with -XX:+DisableAttachMechanism.
  3. Command kill -3 PID doesn't return anything.

It works if I pass -XX:+StartAttachListener to JVM but still .java_pidNNN file is missing in /tmp directory on the host.

Is there any way to fix this issue without passing -XX:+StartAttachListener to JVM?

JDK -
openjdk version "11.0.12" 2021-07-20 LTS
OpenJDK Runtime Environment 18.9 (build 11.0.12+7-LTS)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.12+7-LTS, mixed mode, sharing)

OS -

CentOS Linux release 7.9.2009 (Core)
3.10.0-1160.42.2.el7.x86_64

Capture GC log using jattach

Hi,

I am running one java application without turning on the GC logging. I cannot use jstat because I don't have JDK. When I used jattach <PID> jcmd GC.class_stats > gc.log command, it returns data but as per my understanding, I think that is not a valid GC log format.

Is there any other way to capture a GC log from the running application?

Installation on Linux CentOS

Hello,
Is it possible to install jattach on CentOS? Colleagues are telling me that it is not. The exact system is:
Operating System: CentOS Linux 7 (Core)
CPE OS Name: cpe:/o:centos:centos:7
Kernel: Linux 3.10.0-957.12.1.el7.x86_64

Thanks,
Martin

Issues when using AdoptOpenJDK/OpenJ9

Hi,

I am trying to use this tool to analyze java process (tested it on clean installation of Tomcat9 but I don't think it's important) that uses:

bin ajedro$ ./java -version
openjdk version "1.8.0_222"
OpenJDK Runtime Environment (build 1.8.0_222-b10)
Eclipse OpenJ9 VM (build openj9-0.15.1, JRE 1.8.0 Mac OS X amd64-64-Bit Compressed References 20190717_298 (JIT enabled, AOT enabled)
OpenJ9   - 0f66c6431
OMR      - ec782f26
JCL      - f147086df1 based on jdk8u222-b10)

but I am getting:

hack ajedro$ ./jattach-macos 69525 jcmd "help -all"
Could not start attach mechanism: No such file or directory

Is OpenJ9 supported?

Unable to call jattach from c#/batch script

Hi,
I am trying to test the scenario where i want my c# code to run jattach for given process.
I am getting either error code 87, or
it just hung, on cancellation i can see following statement:
"Connected to remote process
Response code = "

Let me know if there is some work around to this problem.

Attaching Response code = -1

Hello,

I use below command to attach a JVMTI agent to a running JVM process:
./jattach 29341 load libagent.so true DataCentric::MEM_LOAD_UOPS_RETIRED:L1_MISS:precise=2@10000

There's an Agent-OnAttach method inside the libagent.so, and the jvm was started with -XX:+StartAttachListener. But I always got:
Connected to remote JVM
Response code = -1

Any help is appreciated!

Winapi CreateNamedPipe return value should be INVALID_HANDLE_VALUE not NULL

    char pipeName[MAX_PATH];
    sprintf(pipeName, "\\\\.\\pipe\\javatool%d", GetTickCount());
    HANDLE hPipe = CreateNamedPipe(pipeName, PIPE_ACCESS_INBOUND, PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT,
                                   1, 4096, 8192, NMPWAIT_USE_DEFAULT_WAIT, &sec);
    if (hPipe == NULL) {
        print_error("Could not create pipe", GetLastError());
        LocalFree(sec.lpSecurityDescriptor);
        return 1;
    }

should be

    char pipeName[MAX_PATH];
    sprintf(pipeName, "\\\\.\\pipe\\javatool%d", GetTickCount());
    HANDLE hPipe = CreateNamedPipe(pipeName, PIPE_ACCESS_INBOUND, PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT,
                                   1, 4096, 8192, NMPWAIT_USE_DEFAULT_WAIT, &sec);
    if (hPipe == INVALID_HANDLE_VALUE) {
        print_error("Could not create pipe", GetLastError());
        LocalFree(sec.lpSecurityDescriptor);
        return 1;
    }

https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-createnamedpipea

Hang when attaching on Winapi ConnectNamedPipe

jattach process and target jvm process are all run as Administrator.
jattach hang forever at ConnectNamedPipe

// JVM response is read from the pipe and mirrored to stdout
static int read_response(HANDLE hPipe) {
    ConnectNamedPipe(hPipe, NULL);      ///   <----------------       hang here

    char buf[8192];
    DWORD bytesRead;
    if (!ReadFile(hPipe, buf, sizeof(buf) - 1, &bytesRead, NULL)) {
        print_error("Error reading response", GetLastError());
        return 1;
    }

    // First line of response is the command result code
    buf[bytesRead] = 0;
    int result = atoi(buf);

    do {
        fwrite(buf, 1, bytesRead, stdout);
    } while (ReadFile(hPipe, buf, sizeof(buf), &bytesRead, NULL));

    return result;
}

Support of jhsdb jmap

There are not so many options to get actual heap memory usage in a convenient way. And jhsdb is one of them.

jhsdb jmap --pid <pid> --heap
Attaching to process ID 26440, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 14+36-1461

using thread-local object allocation.
Garbage-First (G1) GC with 1 thread(s)

Heap Configuration:
   MinHeapFreeRatio         = 10
   MaxHeapFreeRatio         = 30
   MaxHeapSize              = 643825664 (614.0MB)
   NewSize                  = 31457280 (30.0MB)
   MaxNewSize               = 31457280 (30.0MB)
   OldSize                  = 5452592 (5.1999969482421875MB)
   NewRatio                 = 2
   SurvivorRatio            = 8
   MetaspaceSize            = 21807104 (20.796875MB)
   CompressedClassSpaceSize = 1073741824 (1024.0MB)
   MaxMetaspaceSize         = 17592186044415 MB
   G1HeapRegionSize         = 1048576 (1.0MB)

Heap Usage:
G1 Heap:
   regions  = 614
   capacity = 643825664 (614.0MB)
   used     = 1757520 (1.6761016845703125MB)
   free     = 642068144 (612.3238983154297MB)
   0.27298073038604437% used
G1 Young Generation:
Eden Space:
   regions  = 0
   capacity = 31457280 (30.0MB)
   used     = 0 (0.0MB)
   free     = 31457280 (30.0MB)
   0.0% used
Survivor Space:
   regions  = 0
   capacity = 0 (0.0MB)
   used     = 0 (0.0MB)
   free     = 0 (0.0MB)
   0.0% used
G1 Old Generation:
   regions  = 3
   capacity = 2097152 (2.0MB)
   used     = 1757520 (1.6761016845703125MB)
   free     = 339632 (0.3238983154296875MB)
   83.80508422851562% used

Is it possible to add support of this command?
Thanks

Trouble attaching to JVM on both Windows and Linux

Unable to attach to an OpenJDK 8 64 on both Windows and Linux
On Linux Ubuntu 19.10 JVM responds with the following:

Connected to remote JVM
Response code = -1

If I try to attach on Windows 10 the Java process just quits.

Could not start attach in k8s ephemeral container: couldn't enter target process mnt namespace

start k8s

minikube start --feature-gates=EphemeralContainers=true

start a simple java pod:

kubectl run arthas-demo --image=hengyunabc/atest:0.0.3

Dockerfile:

FROM openjdk:8-jdk
RUN wget https://arthas.aliyun.com/math-game.jar

ENTRYPOINT ["/bin/sh", "-c", "java -jar math-game.jar"]

Check pods status:

$ kubectl get pods
NAME          READY   STATUS    RESTARTS   AGE
arthas-demo   1/1     Running   0          5m58s

Debug ephemeral containers

kubectl debug -it arthas-demo --image=openjdk:8-jdk --target=arthas-demo
root@arthas-demo:/# wget https://github.com/apangin/jattach/releases/download/v1.5/jattach
root@arthas-demo:/# chmod +x ./jattach
root@arthas-demo:/# ./jattach 9 agentProperties
WARNING: couldn't enter target process mnt namespace
Could not start attach mechanism: No such file or directory

containerised jvm's

Is that tool fits to containerised JVM as well?

I have an host which run dockerised JVM app,

this is how I tried to use the tool:

  • grab the jvm process id (containerised)
  • ./jattach threaddump

this is what I've got
Could not start attach mechanism: No such file or directory

Unable to build on Windows using Visual Studio 2010

Tried to create a Windows console project and added the jattach.c code to the project.

Multiple errors.
Doesn't know sys/socket.h, un.h and unistd.h.

What are the equivalent of these in windows ?

Can you #ifndef __WINDOWS conditionally include files for windows and linux ?

Trouble attaching to modified OpenJDK

Not specifically a jattach issue but I really wanted to get in contact with you because you seem to have a good understanding of the Attach API and I could really use some help.

I am trying to attach to a java process and dump the classes at runtime. The java process uses a modified OpenJDK which causes this error every time I try to attach using VirtualMachine.attach(). I tried using your jattach and I get "Could not allocate memory in target process error code 5." I am also not sure if they are disabling the Attach API via command line arguments because the args are hidden. If you have any ideas how I could attach to this process, I would greatly appreciate it.

Error with IBM J9

I use jattach release from 11 Aug 2021
I tried to get stacktrace from ibm wesphere and got error

jattach 28368 threaddump
Connected to remote JVM
ATTACH_ERR command invalid: ATTACH_DIAGNOSTICS:Thread.print,

java -version

java version "1.8.0_171"
Java(TM) SE Runtime Environment (build 8.0.5.17 - pxa6480sr5fp17ifix-20180726_01(SR5 FP17+IJ08001))
IBM J9 VM (build 2.9, JRE 1.8.0 Linux amd64-64-Bit Compressed References 20180725_392885 (JIT enabled, AOT enabled)
OpenJ9   - a8cda37
OMR      - 4d1cb10
IBM      - 21870d6)
JCL - 20180619_01 based on Oracle jdk8u171-b11

is it not really openj9? That's why i got error.
Or There is OpenJ9 support just from specific version?

Attaching to containerized JVM

Attaching to a JVM running in a container requires a bit of trickery. Simply running jattach $PID doesn't work, of course, because jattach tries to write to the current directory of the containerized process, which is in a different mount namespace, and everything goes downhill from there.

However, assuming that /tmp is mapped to the same directory on the host and the container (e.g. using docker -v /tmp:/tmp), the following works:

$ sudo nsenter -t $PID -m touch /proc/1/cwd/.attach_pid1
$ sudo kill -SIGQUIT $PID
$ sudo jattach 1 <command>

The /tmp mapping is needed because the UNIX domain socket is in /tmp/.java_pid1. If the process in the container is not running as root, sudo needs to use the proper user id (because IIRC the JVM checks the other side of the socket to see that it's the same uid).

Can we somehow automate this process within the tool? E.g. if jattach calls setns to enter the target's mount namespace, and parses /proc/$PID/status to figure out the proper PID (in the container's terms) for formatting the .attach_pid and .java_pid paths, then everything would just work, I think. We wouldn't even need the /tmp volume mapping.

The alternative is to tell people to put jattach inside the container, but that's not always possible.

GC log is not captured with JRE 1.7

I am running a java application and jattach on the AWS Elastic Beanstalk instance image (Amazon Linux).

This instance has JRE 1.7 by default. When I executed jattach <PID> jcmd GC.class_stats command, it return the below error message. I have also tried with OpenJDK 1.8 but getting the same error.

Connected to remote JVM
JVM response code = 0
java.lang.IllegalArgumentException: Unknown diagnostic command

jattach version -

jattach 2.0 built on Aug 11 2021

Java version -

java version "1.7.0_261"
OpenJDK Runtime Environment (amzn-2.6.22.1.83.amzn1-x86_64 u261-b02)
OpenJDK 64-Bit Server VM (build 24.261-b02, mixed mode)

openjdk version "1.8.0_302"
OpenJDK Runtime Environment (build 1.8.0_302-b08)
OpenJDK 64-Bit Server VM (build 25.302-b08, mixed mode)

OS -

NAME="Amazon Linux AMI"
VERSION="2018.03"
ID="amzn"
ID_LIKE="rhel fedora"
VERSION_ID="2018.03"
PRETTY_NAME="Amazon Linux AMI 2018.03"
ANSI_COLOR="0;33"
CPE_NAME="cpe:/o:amazon:linux:2018.03:ga"
HOME_URL="http://aws.amazon.com/amazon-linux-ami/"

# add compatibility to MacOS

At the moment jattach apparently is compatible to Windows, Linux and FreeBSD.
I would like to add functionality to MacOS, so that it is possible to use it under Mac as well.

Could not create remote thread (error code = 8)

I am trying to troubleshoot a Java Process for one of our legacy systems, one that doesn't run out of memory, but consistently uses almost all of the system's memory; and it appears that this system is Running on Windows XP.

When I attempt to run
jattach <PID> dumpheap \heapdump\heap.bin

I get the titled error. Some cursory research shows that the call
HANDLE hThread = CreateRemoteThread(hProcess, NULL, 0, code, data, 0, NULL);

is what is causing the issues. Appears to be related to something with the process sessions on older machines vs newer versions of windows (https://stackoverflow.com/questions/40429629/createremotethread-failing-with-error-not-enough-memory). Then again, it could be something else completely.

Should I be running the command host as administrator, or will that not help in this situation?

As a note, I would be willing to work on and submit a PR for this if there ends up being any sort of issue and not user error, but I am mostly unfamiliar with C/Windows APIs. If we can figure out what the issue is, and the direction needed for a fix, I could probably submit something.

Can't load agent in other namespace.

Run two containers.
One was privileged container (docker run -it --privileged=true --pid=host openjdk-8-jdk bash)
I copy jattach into privileged container.

I have copied the file(agent.jar) to another container(spring project) before executing the command

jattach 28509 load instrument false "/agent.jar"

root@a83b8d5684cf:/dosec/memshell_detect# jattach  28509 load instrument false "/agent.jar"
Connected to remote JVM
Response code = 0
return code: 102

pid = 28509 is another container which run springboot demo. I get this pid by docker inspect xxx | grep -i "pid"

container log
The result is the same, whether the container jdk is 8 or 11

2021-05-16 06:52:43.266  INFO 1 --- [           main] com.example.demo.DemoApplication         : Starting DemoApplication v0.0.1-SNAPSHOT using Java 11.0.11 on 1047004b4806 with PID 1 (/app.jar started by root in /)
2021-05-16 06:52:43.268  INFO 1 --- [           main] com.example.demo.DemoApplication         : No active profile set, falling back to default profiles: default
2021-05-16 06:52:43.884  INFO 1 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)
2021-05-16 06:52:43.893  INFO 1 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2021-05-16 06:52:43.893  INFO 1 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.45]
2021-05-16 06:52:43.929  INFO 1 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2021-05-16 06:52:43.929  INFO 1 --- [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 623 ms
2021-05-16 06:52:44.056  INFO 1 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'applicationTaskExecutor'
2021-05-16 06:52:44.183  INFO 1 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with context path ''
2021-05-16 06:52:44.191  INFO 1 --- [           main] com.example.demo.DemoApplication         : Started DemoApplication in 1.218 seconds (JVM running for 1.618)
Exception in thread "Attach Listener" java.lang.reflect.InvocationTargetException
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at java.instrument/sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:513)
        at java.instrument/sun.instrument.InstrumentationImpl.loadClassAndCallAgentmain(InstrumentationImpl.java:535)
Caused by: java.lang.NullPointerException
        at cn.dosec.copagent.Agent.catchThief(Agent.java:79)
        at cn.dosec.copagent.Agent.agentmain(Agent.java:22)
        ... 6 more
Agent failed to start!

Is it possible load agent by this way?

Example to Dump Heap on Remote Machine

I'd like to dump the heap of a process 1234 running on a remote JVM which is on a host named "myhost". How do I specify the host name in the jattach command line?

I see, "The utility to send commands to remote JVM via Dynamic Attach mechanism," but I don't see any arguments to specify the name of the remote host. Does "remote JVM" mean something less than "JVM running on another host?"

jcmd in IBM java 8 OpenJ9

Hi,

I am using IBM java 8 and trying to use jattach to get the output of VM.system_properties, VM.flags, GC.heap_info options.

java version "1.8.0_321"
Java(TM) SE Runtime Environment (build 8.0.7.6 - pxa6480sr7fp6-20220330_01(SR7 FP6))
IBM J9 VM (build 2.9, JRE 1.8.0 Linux amd64-64-Bit Compressed References 20220303_23850 (JIT enabled, AOT enabled)
OpenJ9   - 6890476
OMR      - 1e70123
IBM      - 1b0232b)
JCL - 20220120_01 based on Oracle jdk8u321-b07

But I don't see these options in the list when I run jattach <PID> jcmd help.

Connected to remote JVM
Dump.heap
Dump.java
Dump.snap
Dump.system
GC.class_histogram
GC.heap_dump
GC.run
Thread.print
help
jstat.class

Any idea how can I run these options using jattach?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.