public class MappedMemoryAllocator extends Object implements MemoryAllocator<MappedMemory>
The mapped memory allocator provides direct memory access to memory mapped from a file on disk. The mapped allocator
supports allocating memory in any FileChannel.MapMode. Once the file is mapped and the
memory has been allocated, the mapped allocator provides the memory address of the underlying
MappedByteBuffer for access via Unsafe.
| Modifier and Type | Field and Description |
|---|---|
static FileChannel.MapMode |
DEFAULT_MAP_MODE |
| Constructor and Description |
|---|
MappedMemoryAllocator(File file) |
MappedMemoryAllocator(File file,
FileChannel.MapMode mode) |
MappedMemoryAllocator(File file,
FileChannel.MapMode mode,
long offset) |
MappedMemoryAllocator(RandomAccessFile file,
FileChannel.MapMode mode,
long offset) |
| Modifier and Type | Method and Description |
|---|---|
MappedMemory |
allocate(int size)
Allocates memory.
|
void |
close() |
MappedMemory |
reallocate(MappedMemory memory,
int size)
Reallocates the given memory.
|
public static final FileChannel.MapMode DEFAULT_MAP_MODE
public MappedMemoryAllocator(File file)
public MappedMemoryAllocator(File file, FileChannel.MapMode mode)
public MappedMemoryAllocator(File file, FileChannel.MapMode mode, long offset)
public MappedMemoryAllocator(RandomAccessFile file, FileChannel.MapMode mode, long offset)
public MappedMemory allocate(int size)
MemoryAllocatorallocate in interface MemoryAllocator<MappedMemory>size - The count of the memory to allocate.public MappedMemory reallocate(MappedMemory memory, int size)
MemoryAllocator
When the memory is reallocated, the memory address for the given Memory instance may change. The returned
Memory instance will contain the updated address and count.
reallocate in interface MemoryAllocator<MappedMemory>memory - The memory to reallocate.size - The count to which to reallocate the given memory.public void close()
Copyright © 2013–2019. All rights reserved.