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
-
-
Field Summary
Fields Modifier and Type Field Description static intDEFAULT_CONCURRENCY_LEVELprivate Malloc[]segmentsprivate longsegmentSize-
Fields inherited from class one.nio.mem.Malloc
base, BASE_OFFSET, BIN_COUNT, BIN_SIZE, BIN_SPACE, capacity, CAPACITY_OFFSET, FREE_MASK, HEADER_SIZE, LEFT_OFFSET, MAX_CHUNK, MIN_CHUNK, NEXT_OFFSET, OCCUPIED_MASK, PREV_OFFSET, SIGNATURE_OFFSET, SIGNATURE_V2, SIGNATURE_V3, SIZE_OFFSET
-
-
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()(package private) voidinit()private voidinitSegments(int concurrencyLevel)longmalloc(int size)Mallocsegment(int index)private MallocsegmentByAddress(long address)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, binSize, calloc, chooseBin, getBin, getTotalMemory, getUsedMemory, mallocImpl
-
-
-
-
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)
-
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- Parameters:
n- an index of the segment to return- Returns:
- the
Mallocinstance for the specified segment
-
getFreeMemory
public long getFreeMemory()
- Specified by:
getFreeMemoryin interfaceMallocMXBean- Overrides:
getFreeMemoryin classMalloc
-
malloc
public long malloc(int size)
-
segmentByAddress
private Malloc segmentByAddress(long address)
-
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.
-
initSegments
private void initSegments(int concurrencyLevel)
-
-