Attach Api and agent unloading

Ishaaq Chandy ishaaq at
Thu Oct 15 01:26:44 UTC 2009

Hi all,
Not sure if this is the right forum to ask this, if you know of a more
appropriate one please direct me there.

I am using the awesome Attach API to attach
an java-based agent to a running app. All working perfectly, great API!

Now, I want to know if there is a way to "unattach" the agent. i.e., does
the agent run in a child classloader that can be unloaded on demand thus
freeing up any resources the agent was using?

What I'm trying to get to is an attaching tool that can be run on demand to
attach to a production app - do whatever it needs to do and then clean up
after itself - i.e. stop any new threads it started, close all resources,
unload any new classes it may have loaded up, free up memory it was using
etc, so that the production app can continue running at normal operation
mode, almost as if we never attached to it in the first place. Obviously,
there can be caveats here - if the attached code is written in such a way
that makes it impossible for the classloader to release the classes for GC
then all bets are off.

Looking at the API, it looks like this is not possible, but I just thought
I'd ask on the offchance I am missing something  here.

View this message in context:
Sent from the OpenJDK General discussion mailing list archive at

More information about the discuss mailing list