pyarrow.MemoryPool#

classpyarrow.MemoryPool#

Bases:_Weakrefable

Base class for memory allocation.

Besides tracking its number of allocated bytes, a memory pool alsotakes care of the required 64-byte alignment for Arrow data.

__init__(*args,**kwargs)#

Methods

__init__(*args, **kwargs)

bytes_allocated(self)

Return the number of bytes that are currently allocated from this memory pool.

max_memory(self)

Return the peak memory allocation in this memory pool.

num_allocations(self)

Return the number of allocations or reallocations that were made using this memory pool.

print_stats(self)

Print statistics about this memory pool.

release_unused(self)

Attempt to return to the OS any memory being held onto by the pool.

total_bytes_allocated(self)

Return the total number of bytes that have been allocated from this memory pool.

Attributes

backend_name

The name of the backend used by this MemoryPool (e.g.

backend_name#

The name of the backend used by this MemoryPool (e.g. “jemalloc”).

bytes_allocated(self)#

Return the number of bytes that are currently allocated from thismemory pool.

max_memory(self)#

Return the peak memory allocation in this memory pool.This can be an approximate number in multi-threaded applications.

None is returned if the pool implementation doesn’t know how tocompute this number.

num_allocations(self)#

Return the number of allocations or reallocations that were madeusing this memory pool.

print_stats(self)#

Print statistics about this memory pool.

The output format is implementation-specific. Not all memory poolsimplement this method.

release_unused(self)#

Attempt to return to the OS any memory being held onto by the pool.

This function should not be called except potentially forbenchmarking or debugging as it could be expensive and detrimental toperformance.

This is best effort and may not have any effect on some memory poolsor in some situations (e.g. fragmentation).

total_bytes_allocated(self)#

Return the total number of bytes that have been allocated from thismemory pool.