2015/07/26 - Apache DirectMemory has been retired.

For more information, please explore the Attic.

public interface

Allocator

implements Closeable
org.apache.directmemory.memory.allocator.Allocator
Known Indirect Subclasses

Class Overview

Interface defining interaction with MemoryBuffer

Summary

Public Methods
abstract MemoryBuffer allocate(int size)
Allocates and returns a MemoryBuffer with capacity() set to the given size.
abstract void clear()
Clear all allocated MemoryBuffer, resulting in a empty and ready to deserve Allocator
abstract void free(MemoryBuffer memoryBuffer)
Returns the given MemoryBuffer making it available for a future usage.
abstract int getCapacity()
abstract int getNumber()
[Expand]
Inherited Methods
From interface java.io.Closeable

Public Methods

public abstract MemoryBuffer allocate (int size)

Allocates and returns a MemoryBuffer with capacity() set to the given size. When the allocation fails, it returns either null or throws an BufferOverflowException, depending on the implementation.

Parameters
size : the size in byte to allocate
Returns
  • a MemoryBuffer of the given size, or either return null or throw an BufferOverflowException when the allocation fails.

public abstract void clear ()

Clear all allocated MemoryBuffer, resulting in a empty and ready to deserve Allocator

public abstract void free (MemoryBuffer memoryBuffer)

Returns the given MemoryBuffer making it available for a future usage. Returning twice a MemoryBuffer won't throw an exception.

Parameters
memoryBuffer : the MemoryBuffer to return

public abstract int getCapacity ()

Returns
  • the internal total size that can be allocated

public abstract int getNumber ()

Returns