com.caucho.util
Class FreeList

java.lang.Object
  |
  +--com.caucho.util.FreeList

public final class FreeList
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
FreeList(int initialSize)
          Create a new free list.
 
Method Summary
 java.lang.Object allocate()
          Try to get an object from the free list.
 boolean allowFree(java.lang.Object obj)
           
 void free(java.lang.Object obj)
          Frees the object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FreeList

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

allocate

public java.lang.Object 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 void free(java.lang.Object 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(java.lang.Object obj)