org.simpleframework.util.buffer

## Interface Allocator

All Superinterfaces:
  java.lang.AutoCloseable, java.io.Closeable

All Known Implementing Classes:
  ArrayAllocator, BufferAllocator, FileAllocator, FilterAllocator

    public interface Allocator
    extends java.io.Closeable

The `Allocator` interface is used to describe a resource that can allocate a buffer. This is used so that memory allocation can be implemented as a strategy allowing many different sources of memory. Typically memory will be allocated as an array of bytes but can be a mapped region of shared memory or a file.

Author:
  Niall Gallagher

### Method Summary

Methods
`Buffer` `allocate()` This method is used to allocate a default buffer.
`Buffer` `allocate(int size)` This method is used to allocate a default buffer.
`void` `close()` This method is used to close the allocator so that resources that are occupied by the allocator can be freed.

### Method Detail

#### allocate

    Buffer allocate()
                    throws java.io.IOException

This method is used to allocate a default buffer. Typically this will allocate a buffer of predetermined size, allowing it to grow to an upper limit to accommodate extra data. If the buffer can not be allocated for some reason this throws an exception.

Returns:
  this returns an allocated buffer with a default size
Throws:
  `java.io.IOException`

#### allocate

    Buffer allocate(int size)
                    throws java.io.IOException

This method is used to allocate a default buffer. This is used to allocate a buffer of the specified size, allowing it to grow to an upper limit to accommodate extra data. If the buffer can not be allocated for some reason this throws an exception.

Parameters:
  `size` - this is the initial capacity the buffer should have
Returns:
  this returns an allocated buffer with a specified size
Throws:
  `java.io.IOException`

#### close

    void close()
               throws java.io.IOException

This method is used to close the allocator so that resources that are occupied by the allocator can be freed. This will allow the allocator to be created and closed repeatedly in a single process without holding on to resources such as mapped file buffers or threads.

Specified by:
  `close` in interface `java.lang.AutoCloseable`
Specified by:
  `close` in interface `java.io.Closeable`
Throws:
  `java.io.IOException`