Re: FW: Hiding Class Definitions from Compacting At GC Cycle‏‏

Krystal Mok rednaxelafx at
Mon Jun 2 18:27:52 UTC 2014

Hi Serkan,

Taobao developed something called "GCIH" (GC-Invisible Heap), which is also
an off-heap solution, that might be similar to what you're trying to do. I
was a part of the effort when I worked there.

The JVM part of source code of a very very early version of the GCIH is
available here:

We record the high-water mark whenever we touch a PermGen object when
moving objects into GCIH:

+  if (p->is_klass() || p->is_perm()) {
+    if (GCInvisibleHeap::_top_klass_addr < p) {
+      GCInvisibleHeap::_top_klass_addr = p;
+    }
+    return;
+  }

And then there were multiple ways to do things. In this version of GCIH we
would traverse all objects in GCIH to fixup their klass pointers after the
PermGen has been compacted. There was another version that would simply
prevent the GC from compacting the part of PermGen below our high-water
mark. I'm not sure how it evolved after I left, but the implementation is
much more stable now, so they might have come up with a better way to do it.

Nonetheless, all these solutions require customizing the JVM internals,
which might not be the thing you want to do.

If you target your off-heap solution to only Java 8 or above, and only
targeting HotSpot, however, then you don't have to worry about metadata
objects moving around (at least for now). That's because the PermGen is
removed from GC and moved into a piece of native memory called "Metaspace",
so they're not subject to GC compaction anymore.

I should mention both JRockit and IBM J9 don't have a PermGen even before
Java 8, and their metadata objects are not subject to compaction either.
I guess you're trying to be JVM-implementation-agnostic here, but since not
all JVMs do compaction, and not all JVMs support object pinning, there's no
cross-JVM compatible API that allows you to prevent metadata object from
being compacted.

- Kris

On Sun, Jun 1, 2014 at 11:42 AM, serkan özal <serkanozal86 at>

> Hi all,
> I am not sure that target of mail is this group or not but I don't know
> better one for asking :)
> I am currently working on an OffHeap solution and I have a problem with
> "Compact" phase of GC.As I see at "Compact" phase, location of classes may
> be changed. I tried class pinning with JNI by "NewGlobalRef" method but it
> doesn't prevent compacting. As I understood, it only hides object from
> garbage collected.
> In brief, is there any way to prevent compacting of any specific class
> defition (or object) at GC cycle?Is there any bit, offset or field (such as
> mark_oop) in object header to prevent compacting of fully from GC for any
> specific object or class?
> Thanks in advance.
> --
> Serkan ÖZAL
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the hotspot-gc-dev mailing list