Allocator
@UnstableApi
interface Allocator
DefaultAllocator |
Default implementation of |
A source of allocations.
Summary
Nested types |
|---|
interface Allocator.AllocationNodeA node in a chain of |
Public functions |
|
|---|---|
Allocation! |
allocate()Obtain an |
Int |
Returns the length of each individual |
Int |
Returns the total number of bytes currently allocated. |
Unit |
release(allocation: Allocation!)Releases an |
Unit |
release(allocationNode: Allocator.AllocationNode!)Releases all |
Unit |
trim()Hints to the allocator that it should make a best effort to release any excess |
Public functions
allocate
fun allocate(): Allocation!
Obtain an Allocation.
When the caller has finished with the Allocation, it should be returned by calling release.
| Returns | |
|---|---|
Allocation! |
The |
getIndividualAllocationLength
fun getIndividualAllocationLength(): Int
Returns the length of each individual Allocation.
getTotalBytesAllocated
fun getTotalBytesAllocated(): Int
Returns the total number of bytes currently allocated.
release
fun release(allocation: Allocation!): Unit
Releases an Allocation back to the allocator.
| Parameters | |
|---|---|
allocation: Allocation! |
The |
release
fun release(allocationNode: Allocator.AllocationNode!): Unit
Releases all Allocations in the chain starting at the given AllocationNode.
Implementations must not make memory allocations.
trim
fun trim(): Unit
Hints to the allocator that it should make a best effort to release any excess Allocations.