Class MappedMemory

java.lang.Object
io.atomix.utils.memory.MappedMemory
All Implemented Interfaces:
Memory

public class MappedMemory extends Object implements 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 Details

  • Method Details

    • allocate

      public static MappedMemory allocate(File file, int size)
      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 - If count is greater than MAX_SIZE
    • allocate

      public static MappedMemory allocate(File file, FileChannel.MapMode mode, int size)
      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 - If count is greater than MAX_SIZE
    • flush

      public void flush()
      Flushes the mapped buffer to disk.
    • size

      public int size()
      Description copied from interface: Memory
      Returns the memory count.
      Specified by:
      size in interface Memory
      Returns:
      The memory count.
    • free

      public void free()
      Description copied from interface: Memory
      Frees the memory.
      Specified by:
      free in interface Memory
    • close

      public void close()