Search code examples
javagarbage-collectionbytecodeinstrumentationbytecode-manipulation

Java - instrumenting the Garbage Collector?


Is it possible to inject bytecode into the Garbage Collector? I have a hunch the answer will be "no", but I can't seem to find anything about it online.


Solution

  • No it isn't possible. The JVM's garbage collector is implemented in C.

    You could instrument the GC by downloading the OpenJDK source code, modifying it, and building it.