Quick question

Gary Benson gbenson at redhat.com
Thu Dec 20 09:45:48 PST 2007

Keith McGuigan wrote:
> Gary Benson wrote:
> > How do I allocate a block of memory that won't be considered for
> > garbage collection but that the garbage collector will scan for
> > oops, rewriting them if necessary?
> You can allocate out of the C-heap (see methods/macros in
> share/vm/memory/allocation.hpp) for the memory, and then you'll
> have to create an oops_do()-style method and arrange for it to be
> called during GC.
> How to call the method depends on what your intentions are for the
> references in the memory block, i.e., do you want them to be strong
> GC roots?  Or not roots but just update the pointers?  Since it
> sounds like the latter, then you can refer to the oops_do() methods
> in the string and symbol tables in
> share/vm/classfile/symbolTable.[ch]pp.  The oops iterated over there
> aren't roots either but they just get their pointers updated.  One
> thing to notice in that code path, though, is that the oops_do() is
> only called for full (major) collections since those tables are
> known to only refer to objects in the perm-gen.  If you're referring
> to non-perm-gen objects you'll need your call to be called from a
> minor collection too.
> Hope that helps.

Thank you.  Merry Christmas!


More information about the hotspot-dev mailing list