public interface Allocator
Modifier and Type | Method and Description |
---|---|
Allocation |
allocate()
Obtain an
Allocation . |
void |
blockWhileTotalBytesAllocatedExceeds(int limit)
Blocks execution until the number of bytes allocated is not greater than the limit, or the
thread is interrupted.
|
int |
getIndividualAllocationLength()
Returns the length of each individual
Allocation . |
int |
getTotalBytesAllocated()
Returns the total number of bytes currently allocated.
|
void |
release(Allocation allocation)
Return an
Allocation . |
void |
release(Allocation[] allocations)
Return an array of
Allocation s. |
void |
trim(int targetSize)
Hints to the
Allocator that it should make a best effort to release any memory that it
has allocated, beyond the specified target number of bytes. |
Allocation allocate()
Allocation
.
When the caller has finished with the Allocation
, it should be returned by calling
release(Allocation)
.
Allocation
.void release(Allocation allocation)
Allocation
.allocation
- The Allocation
being returned.void release(Allocation[] allocations)
Allocation
s.allocations
- The array of Allocation
s being returned.void trim(int targetSize)
Allocator
that it should make a best effort to release any memory that it
has allocated, beyond the specified target number of bytes.targetSize
- The target size in bytes.void blockWhileTotalBytesAllocatedExceeds(int limit) throws InterruptedException
limit
- The limit in bytes.InterruptedException
- If the thread is interrupted.int getTotalBytesAllocated()
int getIndividualAllocationLength()
Allocation
.