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
Concurrent implementation of
Malloc.
Divides the whole memory space into several synchronized Malloc-segments to reduce lock contention.- Author:
- Vadim Tsesko
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionMallocMT(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
Modifier and TypeMethodDescriptionintallocatedSize(long address) voidfree(long address) longlongmalloc(int size) segment(int index) segmentFor(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 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
-
MallocMT
-
-
Method Details
-
segments
public int segments() -
segment
-
segmentFor
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
-
verify
public void verify()Description copied from interface:AllocatorVerify the layout of the heap. Expensive operation, used only for debugging purposes.
-