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 ofMalloc. Divides the whole memory space into several synchronizedMalloc-segments to reduce lock contention.- Author:
- Vadim Tsesko
-
-
Field Summary
Fields Modifier and Type Field Description static intDEFAULT_CONCURRENCY_LEVEL
-
Constructor Summary
Constructors Constructor Description MallocMT(long capacity)MallocMT(long capacity, int concurrencyLevel)MallocMT(long base, long capacity)MallocMT(long base, long capacity, int concurrencyLevel)MallocMT(MappedFile mmap)MallocMT(MappedFile mmap, int concurrencyLevel)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intallocatedSize(long address)voidfree(long address)longgetFreeMemory()longmalloc(int size)Mallocsegment(int index)MallocsegmentFor(long n)Deterministically get one of the segments by somelongvalueintsegments()voidverify()Verify the layout of the heap.-
Methods inherited from class one.nio.mem.Malloc
base, calloc, getTotalMemory, getUsedMemory
-
-
-
-
Field Detail
-
DEFAULT_CONCURRENCY_LEVEL
public static final int DEFAULT_CONCURRENCY_LEVEL
- See Also:
- Constant Field Values
-
-
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)
-
MallocMT
public MallocMT(MappedFile mmap)
-
-
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 somelongvalue
-
getFreeMemory
public long getFreeMemory()
- Specified by:
getFreeMemoryin interfaceMallocMXBean- Overrides:
getFreeMemoryin classMalloc
-
malloc
public long malloc(int size)
-
free
public void free(long address)
-
allocatedSize
public int allocatedSize(long address)
- Overrides:
allocatedSizein classMalloc
-
-