Package one.nio.mem
Class FixedSizeAllocator
java.lang.Object
one.nio.mem.FixedSizeAllocator
- All Implemented Interfaces:
Allocator
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final longprotected final longprotected longprotected static final longprotected final longprotected longprotected longprotected AtomicLong -
Constructor Summary
ConstructorsConstructorDescriptionFixedSizeAllocator(long entrySize, long chunkSize) FixedSizeAllocator(long startAddress, long totalMemory, long entrySize) FixedSizeAllocator(long startAddress, long totalMemory, long entrySize, long head) -
Method Summary
Modifier and TypeMethodDescriptionlongcalloc(int size) longprotected intlongvoidfree(long entry) longprotected longgetMemoryFromSystem(long size) longhead()longmalloc()longmalloc(int size) static voidrelocate(long currentPtr, long delta) longlonglonglonglongvoidverify()Verify the layout of the heap.
-
Field Details
-
headOffset
protected static final long headOffset -
head
protected volatile long head -
usedPages
-
startAddress
protected final long startAddress -
entrySize
protected final long entrySize -
chunkSize
protected final long chunkSize -
totalMemory
protected long totalMemory -
totalPages
protected long totalPages
-
-
Constructor Details
-
FixedSizeAllocator
public FixedSizeAllocator(long entrySize, long chunkSize) -
FixedSizeAllocator
public FixedSizeAllocator(long startAddress, long totalMemory, long entrySize) -
FixedSizeAllocator
public FixedSizeAllocator(long startAddress, long totalMemory, long entrySize, long head)
-
-
Method Details
-
relocate
public static void relocate(long currentPtr, long delta) -
head
public long head() -
countFreePages
protected int countFreePages() -
entrySize
public long entrySize() -
chunkSize
public long chunkSize() -
startAddress
public long startAddress() -
totalMemory
public long totalMemory() -
malloc
public long malloc() -
malloc
public long malloc(int size) -
calloc
public long calloc(int size) -
free
public void free(long entry) -
verify
public void verify()Description copied from interface:AllocatorVerify the layout of the heap. Expensive operation, used only for debugging purposes. -
getMemoryFromSystem
protected long getMemoryFromSystem(long size) -
usedPages
public long usedPages() -
totalPages
public long totalPages() -
freePages
public long freePages() -
usedMemory
public long usedMemory()
-