Managed Memory
This is the Dragon managed memory interface for Python
Classes
- exception DragonPoolAllocationNotAvailable
Bases:
DragonPoolError
TBD
- exception DragonPoolAttachFail
Bases:
DragonPoolError
TBD
- exception DragonPoolCreateFail
Bases:
DragonPoolError
TBD
- exception DragonPoolDetachFail
Bases:
DragonPoolError
TBD
- exception DragonPoolError
Bases:
DragonMemoryError
TBD
- class MemoryAlloc
Bases:
object
Cython wrapper object for memory pool allocations.
- classmethod attach(ser_bytes)
Attach to a serialized memory allocation
- Parameters:
ser_bytes – Bytes-like object (memoryview, bytearray, bytes) of a serialized memory descriptor
- Returns:
MemoryAlloc object
- clear(start=0, stop=None)
- clone(offset=0, length=None)
Clone this memory allocation with an offset into it.
- Parameters:
size – offset in bytes into this allocation
- Returns:
New MemoryAlloc object
- Raises:
RuntimeError
- copy(pool: MemoryPool, timeout=None)
Copy an allocation into a pool
- Parameters:
pool – The pool in which to copy it.
- Returns:
A new memory allocation
- Raises:
DragonMemoryError
- detach()
Detach from memory previously attached to.
- free()
Free the managed memory allocation.
- Returns:
None
- Raises:
DragonMemoryError
- get_memview()
Get a memoryview of the underlying memory
- Returns:
Memoryview object
- pool
Return the pool of this memory allocation.
- Returns:
pool where this resides.
- Raises:
DragonMemoryError
- serialize()
Serialize the memory allocation for storage or communication
- Returns:
Memoryview of the serialized data
- size
Return the size of the allocation
return: the size in bytes of the memory allocation
- class MemoryAllocations
Bases:
object
Cython wrapper object to provide access to lists of existing memory allocations in a pool
- alloc_id(idx)
- alloc_type(idx)
Get the type of a particular allocation id.
- Returns:
Enum of the allocation type (if it exists)
- Raises:
RuntimeError if allocation not found
- num_allocs
Number of allocations in pool.
- class MemoryPool
Bases:
object
Cython wrapper for managed memory pools and related structures
- __init__()
Create a new memory pool and return a MemoryPool object.
- Parameters:
size – Size (in bytes) of the pool.
fname – Filename of the pool to use.
uid – Unique pool identifier to use.
mattr – MemoryPoolAttr object to specify various pool attributes. Currently Unused
- Returns:
MemoryPool object
- Raises:
DragonPoolCreateFail
- alloc(size)
Allocate a memory block within this pool. Please note that the internal memory manager allocates to nearest powers of 2.
- Parameters:
size – Size (in bytes) to allocate
- Returns:
New MemoryAlloc object
- Raises:
RuntimeError
- alloc_blocking(size, timeout=None)
Allocate a memory block within this pool. Please note that the internal memory manager allocates to nearest powers of 2.
- Parameters:
size – Size (in bytes) to allocate
- Returns:
New MemoryAlloc object
- Raises:
RuntimeError
- allocation_exists(alloc_type, alloc_id)
Scan the pool to determine if a given allocation exists
- Parameters:
alloc_type – AllocType Enum of the allocation type
alloc_id – Integer ID of the allocation
- Returns:
True if allocation exists, False otherwise
- classmethod attach(pool_ser, *, existing_memory_pool=None)
Attach to an existing pool through a serialized descriptor.
- Parameters:
pool_ser – Bytes-like object of a serialized pool descriptor.
- Returns:
MemoryPool object
- Raises:
DragonPoolAttachFail
- classmethod attach_default()
Attach to the default pool. :return: default memory pool object :raises: DragonPoolAttachFail
- destroy()
Destroy the pool created by this object.
- detach(serialize=False)
Detach from a previously attached to pool by this object.
- Parameters:
serialize – Boolean to optionally store a serializer before detaching
- classmethod empty_pool()
- free_blocks
Return the number of free blocks with different block sizes.
- Returns:
A dictionary with keys as block sizes and values as the number of blocks with the size.
- free_space
- get_alloc_by_id(alloc_type, alloc_id)
Get an allocation object by searching for type and ID
- Parameters:
alloc_type – AllocType Enum of the allocation type
alloc_id – Integer ID of the allocation
- Returns:
New MemoryAlloc object if allocation exists
- Raises:
RuntimeError if allocation does not exist
- get_allocations()
Get a list of allocations in this pool
- Returns:
New MemoryAllocations object
- is_local
- muid
- num_block_sizes
Return the total number of block sizes.
- Returns:
number of block sizes of the pool.
- rt_uid
- serialize()
Serialize the pool held by this object. Will store a copy of the serialized data as part of the object after first call.
- Returns:
Memoryview of serialized pool descriptor.
- classmethod serialized_uid_fname(pool_ser)
- size
- utilization
Enums
- exception DragonPoolAllocationNotAvailable
Bases:
DragonPoolError
TBD
- exception DragonPoolAttachFail
Bases:
DragonPoolError
TBD
- exception DragonPoolCreateFail
Bases:
DragonPoolError
TBD
- exception DragonPoolDetachFail
Bases:
DragonPoolError
TBD
- exception DragonPoolError
Bases:
DragonMemoryError
TBD
- class MemoryAlloc
Bases:
object
Cython wrapper object for memory pool allocations.
- classmethod attach(ser_bytes)
Attach to a serialized memory allocation
- Parameters:
ser_bytes – Bytes-like object (memoryview, bytearray, bytes) of a serialized memory descriptor
- Returns:
MemoryAlloc object
- clear(start=0, stop=None)
- clone(offset=0, length=None)
Clone this memory allocation with an offset into it.
- Parameters:
size – offset in bytes into this allocation
- Returns:
New MemoryAlloc object
- Raises:
RuntimeError
- copy(pool: MemoryPool, timeout=None)
Copy an allocation into a pool
- Parameters:
pool – The pool in which to copy it.
- Returns:
A new memory allocation
- Raises:
DragonMemoryError
- detach()
Detach from memory previously attached to.
- free()
Free the managed memory allocation.
- Returns:
None
- Raises:
DragonMemoryError
- get_memview()
Get a memoryview of the underlying memory
- Returns:
Memoryview object
- pool
Return the pool of this memory allocation.
- Returns:
pool where this resides.
- Raises:
DragonMemoryError
- serialize()
Serialize the memory allocation for storage or communication
- Returns:
Memoryview of the serialized data
- size
Return the size of the allocation
return: the size in bytes of the memory allocation
- class MemoryAllocations
Bases:
object
Cython wrapper object to provide access to lists of existing memory allocations in a pool
- alloc_id(idx)
- alloc_type(idx)
Get the type of a particular allocation id.
- Returns:
Enum of the allocation type (if it exists)
- Raises:
RuntimeError if allocation not found
- num_allocs
Number of allocations in pool.
- class MemoryPool
Bases:
object
Cython wrapper for managed memory pools and related structures
- __init__()
Create a new memory pool and return a MemoryPool object.
- Parameters:
size – Size (in bytes) of the pool.
fname – Filename of the pool to use.
uid – Unique pool identifier to use.
mattr – MemoryPoolAttr object to specify various pool attributes. Currently Unused
- Returns:
MemoryPool object
- Raises:
DragonPoolCreateFail
- alloc(size)
Allocate a memory block within this pool. Please note that the internal memory manager allocates to nearest powers of 2.
- Parameters:
size – Size (in bytes) to allocate
- Returns:
New MemoryAlloc object
- Raises:
RuntimeError
- alloc_blocking(size, timeout=None)
Allocate a memory block within this pool. Please note that the internal memory manager allocates to nearest powers of 2.
- Parameters:
size – Size (in bytes) to allocate
- Returns:
New MemoryAlloc object
- Raises:
RuntimeError
- allocation_exists(alloc_type, alloc_id)
Scan the pool to determine if a given allocation exists
- Parameters:
alloc_type – AllocType Enum of the allocation type
alloc_id – Integer ID of the allocation
- Returns:
True if allocation exists, False otherwise
- classmethod attach(pool_ser, *, existing_memory_pool=None)
Attach to an existing pool through a serialized descriptor.
- Parameters:
pool_ser – Bytes-like object of a serialized pool descriptor.
- Returns:
MemoryPool object
- Raises:
DragonPoolAttachFail
- classmethod attach_default()
Attach to the default pool. :return: default memory pool object :raises: DragonPoolAttachFail
- destroy()
Destroy the pool created by this object.
- detach(serialize=False)
Detach from a previously attached to pool by this object.
- Parameters:
serialize – Boolean to optionally store a serializer before detaching
- classmethod empty_pool()
- free_blocks
Return the number of free blocks with different block sizes.
- Returns:
A dictionary with keys as block sizes and values as the number of blocks with the size.
- free_space
- get_alloc_by_id(alloc_type, alloc_id)
Get an allocation object by searching for type and ID
- Parameters:
alloc_type – AllocType Enum of the allocation type
alloc_id – Integer ID of the allocation
- Returns:
New MemoryAlloc object if allocation exists
- Raises:
RuntimeError if allocation does not exist
- get_allocations()
Get a list of allocations in this pool
- Returns:
New MemoryAllocations object
- is_local
- muid
- num_block_sizes
Return the total number of block sizes.
- Returns:
number of block sizes of the pool.
- rt_uid
- serialize()
Serialize the pool held by this object. Will store a copy of the serialized data as part of the object after first call.
- Returns:
Memoryview of serialized pool descriptor.
- classmethod serialized_uid_fname(pool_ser)
- size
- utilization
Exceptions
- exception DragonPoolAllocationNotAvailable
Bases:
DragonPoolError
TBD
- exception DragonPoolAttachFail
Bases:
DragonPoolError
TBD
- exception DragonPoolCreateFail
Bases:
DragonPoolError
TBD
- exception DragonPoolDetachFail
Bases:
DragonPoolError
TBD
- exception DragonPoolError
Bases:
DragonMemoryError
TBD
- class MemoryAlloc
Bases:
object
Cython wrapper object for memory pool allocations.
- classmethod attach(ser_bytes)
Attach to a serialized memory allocation
- Parameters:
ser_bytes – Bytes-like object (memoryview, bytearray, bytes) of a serialized memory descriptor
- Returns:
MemoryAlloc object
- clear(start=0, stop=None)
- clone(offset=0, length=None)
Clone this memory allocation with an offset into it.
- Parameters:
size – offset in bytes into this allocation
- Returns:
New MemoryAlloc object
- Raises:
RuntimeError
- copy(pool: MemoryPool, timeout=None)
Copy an allocation into a pool
- Parameters:
pool – The pool in which to copy it.
- Returns:
A new memory allocation
- Raises:
DragonMemoryError
- detach()
Detach from memory previously attached to.
- free()
Free the managed memory allocation.
- Returns:
None
- Raises:
DragonMemoryError
- get_memview()
Get a memoryview of the underlying memory
- Returns:
Memoryview object
- pool
Return the pool of this memory allocation.
- Returns:
pool where this resides.
- Raises:
DragonMemoryError
- serialize()
Serialize the memory allocation for storage or communication
- Returns:
Memoryview of the serialized data
- size
Return the size of the allocation
return: the size in bytes of the memory allocation
- class MemoryAllocations
Bases:
object
Cython wrapper object to provide access to lists of existing memory allocations in a pool
- alloc_id(idx)
- alloc_type(idx)
Get the type of a particular allocation id.
- Returns:
Enum of the allocation type (if it exists)
- Raises:
RuntimeError if allocation not found
- num_allocs
Number of allocations in pool.
- class MemoryPool
Bases:
object
Cython wrapper for managed memory pools and related structures
- __init__()
Create a new memory pool and return a MemoryPool object.
- Parameters:
size – Size (in bytes) of the pool.
fname – Filename of the pool to use.
uid – Unique pool identifier to use.
mattr – MemoryPoolAttr object to specify various pool attributes. Currently Unused
- Returns:
MemoryPool object
- Raises:
DragonPoolCreateFail
- alloc(size)
Allocate a memory block within this pool. Please note that the internal memory manager allocates to nearest powers of 2.
- Parameters:
size – Size (in bytes) to allocate
- Returns:
New MemoryAlloc object
- Raises:
RuntimeError
- alloc_blocking(size, timeout=None)
Allocate a memory block within this pool. Please note that the internal memory manager allocates to nearest powers of 2.
- Parameters:
size – Size (in bytes) to allocate
- Returns:
New MemoryAlloc object
- Raises:
RuntimeError
- allocation_exists(alloc_type, alloc_id)
Scan the pool to determine if a given allocation exists
- Parameters:
alloc_type – AllocType Enum of the allocation type
alloc_id – Integer ID of the allocation
- Returns:
True if allocation exists, False otherwise
- classmethod attach(pool_ser, *, existing_memory_pool=None)
Attach to an existing pool through a serialized descriptor.
- Parameters:
pool_ser – Bytes-like object of a serialized pool descriptor.
- Returns:
MemoryPool object
- Raises:
DragonPoolAttachFail
- classmethod attach_default()
Attach to the default pool. :return: default memory pool object :raises: DragonPoolAttachFail
- destroy()
Destroy the pool created by this object.
- detach(serialize=False)
Detach from a previously attached to pool by this object.
- Parameters:
serialize – Boolean to optionally store a serializer before detaching
- classmethod empty_pool()
- free_blocks
Return the number of free blocks with different block sizes.
- Returns:
A dictionary with keys as block sizes and values as the number of blocks with the size.
- free_space
- get_alloc_by_id(alloc_type, alloc_id)
Get an allocation object by searching for type and ID
- Parameters:
alloc_type – AllocType Enum of the allocation type
alloc_id – Integer ID of the allocation
- Returns:
New MemoryAlloc object if allocation exists
- Raises:
RuntimeError if allocation does not exist
- get_allocations()
Get a list of allocations in this pool
- Returns:
New MemoryAllocations object
- is_local
- muid
- num_block_sizes
Return the total number of block sizes.
- Returns:
number of block sizes of the pool.
- rt_uid
- serialize()
Serialize the pool held by this object. Will store a copy of the serialized data as part of the object after first call.
- Returns:
Memoryview of serialized pool descriptor.
- classmethod serialized_uid_fname(pool_ser)
- size
- utilization