Package com.google.android.exoplayer2.upstream

## Interface Allocator

- All Known Implementing Classes:
    `DefaultAllocator`

      public interface Allocator

  A source of allocations.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Interface | Description
    --- | --- | ---
    `static interface` | `Allocator.AllocationNode` | A node in a chain of `Allocations`.

  - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method | 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​(Allocator.AllocationNode allocationNode)` | Releases all `Allocations` in the chain starting at the given `Allocator.AllocationNode`.
    `void` | `trim()` | Hints to the allocator that it should make a best effort to release any excess `Allocations`.

- - ### Method Detail

    - #### allocate

          Allocation allocate()

      Obtain an `Allocation`.

      When the caller has finished with the `Allocation`, it should be returned by calling `release(Allocation)`.

      Returns:
        The `Allocation`.

    - #### release

          void release​(Allocation allocation)

      Releases an `Allocation` back to the allocator.
      Parameters:
        `allocation` - The `Allocation` being released.

    - #### release

          void release​(Allocator.AllocationNode allocationNode)

      Releases all `Allocations` in the chain starting at the given `Allocator.AllocationNode`.

      Implementations must not make memory allocations.

    - #### trim

          void trim()

      Hints to the allocator that it should make a best effort to release any excess `Allocations`.

    - #### getTotalBytesAllocated

          int getTotalBytesAllocated()

      Returns the total number of bytes currently allocated.

    - #### getIndividualAllocationLength

          int getIndividualAllocationLength()

      Returns the length of each individual `Allocation`.