Package io.atomix.utils.memory
Class MappedMemory
java.lang.Object
io.atomix.utils.memory.MappedMemory
- All Implemented Interfaces:
Memory
Mapped memory.
This is a special memory descriptor that handles management of MappedByteBuffer based
memory. The mapped memory descriptor simply points to the memory address of the underlying byte
buffer. When memory is reallocated, the parent MappedMemoryAllocator is used to create a
new MappedByteBuffer and free the existing buffer.
- Author:
- Jordan Halterman
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic MappedMemoryAllocates memory mapped to a file on disk.static MappedMemoryallocate(File file, FileChannel.MapMode mode, int size) Allocates memory mapped to a file on disk.voidclose()voidflush()Flushes the mapped buffer to disk.voidfree()Frees the memory.intsize()Returns the memory count.
-
Constructor Details
-
MappedMemory
-
-
Method Details
-
allocate
Allocates memory mapped to a file on disk.- Parameters:
file- The file to which to map memory.size- The count of the memory to map.- Returns:
- The mapped memory.
- Throws:
IllegalArgumentException- Ifcountis greater thanMAX_SIZE
-
allocate
Allocates memory mapped to a file on disk.- Parameters:
file- The file to which to map memory.mode- The mode with which to map memory.size- The count of the memory to map.- Returns:
- The mapped memory.
- Throws:
IllegalArgumentException- Ifcountis greater thanMAX_SIZE
-
flush
public void flush()Flushes the mapped buffer to disk. -
size
public int size()Description copied from interface:MemoryReturns the memory count. -
free
public void free()Description copied from interface:MemoryFrees the memory. -
close
public void close()
-