public interface MemoryManager
Internally, memory is represented as byte arrays. The memory manager acts like a distributer for memory, which means it assigns portions of the arrays to tasks. If memory is released, it means that this part of the memory can be assigned to other tasks.
| Modifier and Type | Method and Description |
|---|---|
List<MemorySegment> |
allocatePages(AbstractInvokable owner,
int numPages) |
void |
allocatePages(AbstractInvokable owner,
List<MemorySegment> target,
int numPages) |
long |
computeMemorySize(double fraction)
Computes the memory size of the fraction per slot.
|
int |
computeNumberOfPages(double fraction)
Computes to how many pages the given number of bytes corresponds.
|
long |
getMemorySize()
Returns the total size of memory.
|
int |
getPageSize()
Gets the size of the pages handled by the memory manager.
|
<T extends MemorySegment> |
release(Collection<T> segments)
Tries to release the memory for the specified collection of segments.
|
void |
release(MemorySegment segment)
Tries to release the memory for the specified segment.
|
void |
releaseAll(AbstractInvokable task)
Releases all memory segments for the given task.
|
long |
roundDownToPageSizeMultiple(long numBytes)
Rounds the given value down to a multiple of the memory manager's page size.
|
void |
shutdown()
Shuts the memory manager down, trying to release all the memory it managed.
|
boolean |
verifyEmpty()
Checks if the memory manager all memory available and the descriptors of the free segments
describe a contiguous memory layout.
|
List<MemorySegment> allocatePages(AbstractInvokable owner, int numPages) throws MemoryAllocationException
MemoryAllocationExceptionvoid allocatePages(AbstractInvokable owner, List<MemorySegment> target, int numPages) throws MemoryAllocationException
MemoryAllocationExceptionvoid release(MemorySegment segment)
segment has already been released or
is null, the request is simply ignored. If the segment is not from the expected
MemorySegment implementation type, an IllegalArgumentException is thrown.segment - The segment to be released.IllegalArgumentException - Thrown, if the given segment is of an incompatible type.<T extends MemorySegment> void release(Collection<T> segments)
T - The type of memory segment.segments - The segments to be released.NullPointerException - Thrown, if the given collection is null.IllegalArgumentException - Thrown, id the segments are of an incompatible type.void releaseAll(AbstractInvokable task)
task - The task whose memory segments are to be released.int getPageSize()
long getMemorySize()
int computeNumberOfPages(double fraction)
fraction - the fraction of the total memory per slotlong computeMemorySize(double fraction)
fraction - The fraction of the memory of the task slot.long roundDownToPageSizeMultiple(long numBytes)
void shutdown()
boolean verifyEmpty()
Copyright © 2014 The Apache Software Foundation. All rights reserved.