public class ArrayListHeap
extends java.lang.Object
ArrayListHeap
class is a utility class which keeps
a cache of empty ArrayList instances for quick reuse. During the
course of a regular parse of a 200k Java file for example, about
2700 ArrayList's are allocated, then discarded. Generally no more
than about 30-40 lists are allocated at any given time. By pooling these together into a cache/heap, we can reduce the frequency of allocations and GC's necessary for these ArrayLists. If you use this class, you MUST follow the contract that all allocated lists from this pool must be freed back to this pool.
Constructor and Description |
---|
ArrayListHeap() |
Modifier and Type | Method and Description |
---|---|
protected static java.util.ArrayList |
allocArrayList()
Utility routine to allocate an ArrayList instance from the
heap.
|
protected static void |
freeArrayList(java.util.ArrayList list)
Utility routine to free an ArrayList instance back to the
heap to allow it to be reused.
|
protected static java.util.ArrayList allocArrayList()
protected static void freeArrayList(java.util.ArrayList list)
list
- the list to free