Package one.nio.mem

Class 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.
    • Field Detail

      • DEFAULT_CONCURRENCY_LEVEL

        public static final int DEFAULT_CONCURRENCY_LEVEL
        See Also:
        Constant Field Values
      • segments

        private Malloc[] segments
      • segmentSize

        private long segmentSize
    • Constructor Detail

      • 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)
    • Method Detail

      • 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
        Parameters:
        n - an index of the segment to return
        Returns:
        the Malloc instance for the specified segment
      • segmentByAddress

        private Malloc segmentByAddress​(long address)
      • 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
      • init

        void init()
        Overrides:
        init in class Malloc
      • initSegments

        private void initSegments​(int concurrencyLevel)