com.sas.util
Class GCBarrier

com.sas.util.GCBarrier

public class GCBarrier

A class which maintains references to other objects behind a garbage collection barrier. Any object added via the preventGarbageCollection(java.lang.Object) method will not be garbage collected. This is useful especially for certain classes which you do not want collected since reloading them may break them. This may be necessary if a class' static initializers must only be executed once per Java Virtual Machine process. For example, this class has a static initializer block which does:

 static
  {
    GCBarrier.preventGarbageCollection(com.sas.util.GCBarrier.class);
  }
 

This class is no longer needed to prevent a Class object from being garbage collected. In JDK1.3, Class objects are not garbage collected until the ClassLoader that loaded them is garbage collected.


Method Summary
static void allowGarbageCollection(java.lang.Object object)
          Allow an object that had been prevented from being garbage collected to be collected.
static void preventGarbageCollection(java.lang.Object object)
          Prevent an object from being garbage collected by saving a reference to it in non-collected space.
 

Method Detail

preventGarbageCollection

public static void preventGarbageCollection(java.lang.Object object)
Prevent an object from being garbage collected by saving a reference to it in non-collected space.

Parameters:
object - the object you don't want collected.

allowGarbageCollection

public static void allowGarbageCollection(java.lang.Object object)
Allow an object that had been prevented from being garbage collected to be collected.




Copyright © 2009 SAS Institute Inc. All Rights Reserved.