def test_set_memory_pool(): old_pool = pa.default_memory_pool() pool = pa.proxy_memory_pool(old_pool) pa.set_memory_pool(pool) try: allocated_before = pool.bytes_allocated() with allocate_bytes(None, 512): assert pool.bytes_allocated() == allocated_before + 512 assert pool.bytes_allocated() == allocated_before finally: pa.set_memory_pool(old_pool)
def test_set_memory_pool(): old_pool = pa.default_memory_pool() pool = pa.proxy_memory_pool(old_pool) pa.set_memory_pool(pool) try: allocated_before = pool.bytes_allocated() with allocate_bytes(None, 512): assert pool.bytes_allocated() == allocated_before + 512 assert pool.bytes_allocated() == allocated_before finally: pa.set_memory_pool(old_pool)
def test_default_memory_pool(): gc.collect() bytes_before_default = pa.total_allocated_bytes() bytes_before_jemalloc = pa.jemalloc_memory_pool().bytes_allocated() old_memory_pool = pa.default_memory_pool() pa.set_memory_pool(pa.jemalloc_memory_pool()) array = pa.array([1, None, 3, None]) # noqa pa.set_memory_pool(old_memory_pool) gc.collect() assert pa.total_allocated_bytes() == bytes_before_default assert (pa.jemalloc_memory_pool().bytes_allocated() > bytes_before_jemalloc)
def test_default_memory_pool(): gc.collect() bytes_before_default = pa.total_allocated_bytes() bytes_before_jemalloc = pa.jemalloc_memory_pool().bytes_allocated() old_memory_pool = pa.default_memory_pool() pa.set_memory_pool(pa.jemalloc_memory_pool()) array = pa.array([1, None, 3, None]) # noqa pa.set_memory_pool(old_memory_pool) gc.collect() assert pa.total_allocated_bytes() == bytes_before_default assert (pa.jemalloc_memory_pool().bytes_allocated() > bytes_before_jemalloc)