| Constructor and Description |
|---|
DefaultAllocator(boolean trimOnReset,
int individualAllocationSize)
Constructs an instance without creating any
Allocations up front. |
DefaultAllocator(boolean trimOnReset,
int individualAllocationSize,
int initialAllocationCount)
Constructs an instance with some
Allocations created up front. |
| Modifier and Type | Method and Description |
|---|---|
Allocation |
allocate()
Obtain an
Allocation. |
int |
getIndividualAllocationLength()
Returns the length of each individual
Allocation. |
int |
getTotalBytesAllocated()
Returns the total number of bytes currently allocated.
|
void |
release(Allocation allocation)
Releases an
Allocation back to the allocator. |
void |
release(Allocation[] allocations)
Releases an array of
Allocations back to the allocator. |
void |
reset() |
void |
setTargetBufferSize(int targetBufferSize) |
void |
trim()
Hints to the allocator that it should make a best effort to release any excess
Allocations. |
public DefaultAllocator(boolean trimOnReset,
int individualAllocationSize)
Allocations up front.trimOnReset - Whether memory is freed when the allocator is reset. Should be true unless
the allocator will be re-used by multiple player instances.individualAllocationSize - The length of each individual Allocation.public DefaultAllocator(boolean trimOnReset,
int individualAllocationSize,
int initialAllocationCount)
Allocations created up front.
Note: Allocations created up front will never be discarded by trim().
trimOnReset - Whether memory is freed when the allocator is reset. Should be true unless
the allocator will be re-used by multiple player instances.individualAllocationSize - The length of each individual Allocation.initialAllocationCount - The number of allocations to create up front.public void reset()
public void setTargetBufferSize(int targetBufferSize)
public Allocation allocate()
AllocatorAllocation.
When the caller has finished with the Allocation, it should be returned by calling
Allocator.release(Allocation).
allocate in interface AllocatorAllocation.public void release(Allocation allocation)
AllocatorAllocation back to the allocator.release in interface Allocatorallocation - The Allocation being released.public void release(Allocation[] allocations)
AllocatorAllocations back to the allocator.release in interface Allocatorallocations - The array of Allocations being released.public void trim()
AllocatorAllocations.public int getTotalBytesAllocated()
AllocatorgetTotalBytesAllocated in interface Allocatorpublic int getIndividualAllocationLength()
AllocatorAllocation.getIndividualAllocationLength in interface Allocator