| 3961 | |
| 3962 | |
| 3963 | def test_table_uses_memory_pool(): |
| 3964 | N = 10000 |
| 3965 | arr = pa.array(np.arange(N, dtype=np.int64)) |
| 3966 | t = pa.table([arr, arr, arr], ['f0', 'f1', 'f2']) |
| 3967 | |
| 3968 | gc.collect() |
| 3969 | prior_allocation = pa.total_allocated_bytes() |
| 3970 | x = t.to_pandas() |
| 3971 | |
| 3972 | new_allocation = 3 * N * 8 |
| 3973 | if _pandas_api.uses_string_dtype(): |
| 3974 | # for the small columns Index |
| 3975 | new_allocation += 128 |
| 3976 | |
| 3977 | assert pa.total_allocated_bytes() == (prior_allocation + new_allocation) |
| 3978 | |
| 3979 | # Check successful garbage collection |
| 3980 | x = None # noqa |
| 3981 | gc.collect() |
| 3982 | assert pa.total_allocated_bytes() == prior_allocation |
| 3983 | |
| 3984 | |
| 3985 | def test_object_leak_in_numpy_array(): |