Every
CodeInfo object has a corresponding
CodeInfoTether that is used for
managing the lifecycle of the unmanaged memory that is used for the
CodeInfo object. As
long as the
CodeInfoTether is reachable by the GC, the
CodeInfo object and its
data will stay alive as well. If the
CodeInfoTether is unreachable, the GC can decide to
free the unmanaged memory at any subsequent safepoint.
Note however that frames on the stack can be deoptimized at any safepoint check, regardless of
the reachability of the code's corresponding CodeInfoTether object. Later lookups via the
instruction pointer can fail, so only the explicitly kept alive CodeInfo must be used.
This also applies to usages within VMOperations as a GC can also be triggered there.