Skip to content
Advertisement

what’s the benefit of using Serviceability Agent when debuging HotspotJVM under linux?

in linux, the Hotspot Serviceability Agent is implemented by ptrace, which will stop the debugee process. Since it has side effect on target JVM, why not just simply attach to that JVM?

If SA has no impact on target JVM, then it’s very useful. But the truth is not. So I’m wonder what’s the meaning of using SA in linux?

Advertisement

Answer

You cannot attach to a Java process which does not respond to an attach command. So the main benefit of the dynamic attach is on the other hand its disadvantage: attach works only with a live and healthy JVM.

Meanwhile, Serviceability Agent does not depend on the JVM cooperation. It works even when the target process is stuck, or deadlocked, or overloaded, or otherwise cannot service requests. It works even with a dead JVM. Yes, you can use SA for postmortem analysis of a coredump.

As you noticed in the title, SA is used for debugging a JVM. The attach mechanism relies on the fact that JVM works and works correctly – from this point of view, it’s useless for finding bugs in the JVM itself. In this situation, you’ll need an external tool, like SA.

References

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement