pitrou commented on a change in pull request #10186:
URL: https://github.com/apache/arrow/pull/10186#discussion_r622155631
##########
File path: cpp/src/arrow/memory_pool.h
##########
@@ -87,6 +87,11 @@ class ARROW_EXPORT MemoryPool {
/// faster deallocation if supported by its backend.
virtual void Free(uint8_t* buffer, int64_t size) = 0;
+ /// Returns unused memory to the OS
Review comment:
"Return"
##########
File path: python/pyarrow/memory.pxi
##########
@@ -36,6 +36,15 @@ cdef class MemoryPool(_Weakrefable):
cdef void init(self, CMemoryPool* pool):
self.pool = pool
+ def release_unused(self):
+ """
+ Attempts to free any memory being held onto by an optimized allocator.
+ This function should not be called except potentially for benchmarking
+ or debugging as it could be expensive and detrimental to performance.
+ """
+ cdef CMemoryPool* pool = c_get_memory_pool()
+ pool.ReleaseUnused()
Review comment:
I think we can enclose this in `with nogil` as releasing memory might be
an expensive operation?
##########
File path: cpp/src/arrow/memory_pool.h
##########
@@ -87,6 +87,11 @@ class ARROW_EXPORT MemoryPool {
/// faster deallocation if supported by its backend.
virtual void Free(uint8_t* buffer, int64_t size) = 0;
+ /// Returns unused memory to the OS
+ ///
+ /// Only applies to allocators that hold onto unused memory
Review comment:
Mention that this is a best effort only? Even an allocator which exposes
such a facility may not release all "unused" memory (for example because of
memory fragmentation).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]