Package one.nio.mem

Class MallocMT

java.lang.Object
one.nio.mem.Malloc
one.nio.mem.MallocMT
All Implemented Interfaces:
Allocator, MallocMXBean
Direct Known Subclasses:
MallocAnalyzer

public class MallocMT extends Malloc
Concurrent implementation of Malloc. Divides the whole memory space into several synchronized Malloc-segments to reduce lock contention.
Author:
Vadim Tsesko
  • Field Details

    • DEFAULT_CONCURRENCY_LEVEL

      public static final int DEFAULT_CONCURRENCY_LEVEL
      See Also:
  • Constructor Details

    • MallocMT

      public MallocMT(long capacity, int concurrencyLevel)
    • MallocMT

      public MallocMT(long capacity)
    • MallocMT

      public MallocMT(long base, long capacity, int concurrencyLevel)
    • MallocMT

      public MallocMT(long base, long capacity)
    • MallocMT

      public MallocMT(MappedFile mmap, int concurrencyLevel)
    • MallocMT

      public MallocMT(MappedFile mmap)
  • Method Details

    • segments

      public int segments()
    • segment

      public Malloc segment(int index)
    • segmentFor

      public Malloc segmentFor(long n)
      Deterministically get one of the segments by some long value
    • getFreeMemory

      public long getFreeMemory()
      Specified by:
      getFreeMemory in interface MallocMXBean
      Overrides:
      getFreeMemory in class Malloc
    • malloc

      public long malloc(int size)
      Specified by:
      malloc in interface Allocator
      Overrides:
      malloc in class Malloc
    • free

      public void free(long address)
      Specified by:
      free in interface Allocator
      Overrides:
      free in class Malloc
    • allocatedSize

      public int allocatedSize(long address)
      Overrides:
      allocatedSize in class Malloc
    • verify

      public void verify()
      Description copied from interface: Allocator
      Verify the layout of the heap. Expensive operation, used only for debugging purposes.
      Specified by:
      verify in interface Allocator
      Overrides:
      verify in class Malloc