Class HessianFreeList<T>


  • public final class HessianFreeList<T>
    extends java.lang.Object
    FreeList provides a simple class to manage free objects. This is useful for large data structures that otherwise would gobble up huge GC time.

    The free list is bounded. Freeing an object when the list is full will do nothing.

    • Constructor Summary

      Constructors 
      Constructor Description
      HessianFreeList​(int size)
      Create a new free list.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      T allocate()
      Try to get an object from the free list.
      boolean allowFree​(T obj)  
      boolean checkDuplicate​(T obj)
      Debugging to see if the object has already been freed.
      boolean free​(T obj)
      Frees the object.
      void freeCareful​(T obj)
      Frees the object.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • HessianFreeList

        public HessianFreeList​(int size)
        Create a new free list.
        Parameters:
        initialSize - maximum number of free objects to store.
    • Method Detail

      • allocate

        public T allocate()
        Try to get an object from the free list. Returns null if the free list is empty.
        Returns:
        the new object or null.
      • free

        public boolean free​(T obj)
        Frees the object. If the free list is full, the object will be garbage collected.
        Parameters:
        obj - the object to be freed.
      • allowFree

        public boolean allowFree​(T obj)
      • freeCareful

        public void freeCareful​(T obj)
        Frees the object. If the free list is full, the object will be garbage collected.
        Parameters:
        obj - the object to be freed.
      • checkDuplicate

        public boolean checkDuplicate​(T obj)
        Debugging to see if the object has already been freed.