User1291
User1291

Reputation: 8182

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.

Upvotes: 0

Views: 129

Answers (2)

shijie xu
shijie xu

Reputation: 2097

It is not possible to inject bytecode to GC. Bytecode and GC are two related areas, but not at the same level. Bytecode is a higher level language, while GC of VM(e.g., IBM J9, and Hotsppot) are at lower level, and mostly implemented in the C/C++/ languages. Bytecode interpretation normally is converted to native code execution via JNI calls.

Object inlining is one runtime optimization, and there are more than one definition for it. Similar to Christian's work, I also did many object inlining, which was different from Christian optimizations for Hotspot. You can have a look https://dl.acm.org/citation.cfm?id=3141874

As runtime optimization and GC are two key topics in the VM, researchers normally would figure out the impact among the optimization one is doing and other measurements. This may be the motivation you asked the question and the object inlining in Christan's work.

Upvotes: 1

Stephen C
Stephen C

Reputation: 718768

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.

Upvotes: 3

Related Questions