oracle.javatools.parser.util
Class ArrayListHeap
java.lang.Object
oracle.javatools.parser.util.ArrayListHeap
- Direct Known Subclasses:
- ExpressionStack
- public class ArrayListHeap
- extends java.lang.Object
The 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.
Method Summary |
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. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ArrayListHeap
public ArrayListHeap()
allocArrayList
protected static java.util.ArrayList allocArrayList()
- Utility routine to allocate an ArrayList instance from the heap. This will reuse ArrayLists if possible.
-
- Returns:
- an empty ArrayList
freeArrayList
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.
-
- Parameters:
list
- the list to free
Copyright © 1997, 2004, Oracle. All rights reserved.