| 3862 | # to_pandas uses MemoryPool |
| 3863 | |
| 3864 | def test_array_uses_memory_pool(): |
| 3865 | # ARROW-6570 |
| 3866 | N = 10000 |
| 3867 | arr = pa.array(np.arange(N, dtype=np.int64), |
| 3868 | mask=np.random.randint(0, 2, size=N).astype(np.bool)) |
| 3869 | |
| 3870 | # In the case the gc is caught loading |
| 3871 | gc.collect() |
| 3872 | |
| 3873 | prior_allocation = pa.total_allocated_bytes() |
| 3874 | |
| 3875 | x = arr.to_pandas() |
| 3876 | assert pa.total_allocated_bytes() == (prior_allocation + N * 8) |
| 3877 | x = None # noqa |
| 3878 | gc.collect() |
| 3879 | |
| 3880 | assert pa.total_allocated_bytes() == prior_allocation |
| 3881 | |
| 3882 | # zero copy does not allocate memory |
| 3883 | arr = pa.array(np.arange(N, dtype=np.int64)) |
| 3884 | |
| 3885 | prior_allocation = pa.total_allocated_bytes() |
| 3886 | x = arr.to_pandas() # noqa |
| 3887 | assert pa.total_allocated_bytes() == prior_allocation |
| 3888 | |
| 3889 | |
| 3890 | def test_singleton_blocks_zero_copy(): |