You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Python] Cannot release memory after reading a parquet file from S3 #45882
This behavior happens with pyarrow v18 and v19 but not v17. See this memory profile (total memory used given by btop) with a loop of 5 pq.read_table('data.parquet') for pyarrow v19 first, then v18, then v17:
The memory is released after each loop iteration for pyarrow v17 only.
Because of this issue, experimenting with pyarrow & parquet inside jupyter notebooks leads to increasing memory usage until the next kernel restart. It is less problematic for single task scripts that release the memory at the end anyway.
After some investigation, it appears that the difference between versions in the memory profile above is explained by the choice of memory allocator: jemalloc by default for v17 vs mimalloc for v18 and v19.
Below is a new memory profile with pyarrow==19.0.1 for mimalloc on the left and jemalloc on the right (loop of 5 iteration of parquet file reading).
You can set jemalloc as the default memory allocator using: export ARROW_DEFAULT_MEMORY_POOL=jemalloc
See:
The default memory pool has changed to mimalloc on all platforms (GH-43254). Previously, jemalloc was used by default on Linux. Using mimalloc by default provides a more consistent experience across different platforms, and makes configuration easier. It is expected that this might either increase or decrease performance on user workloads that use the default memory pool; please benchmark accordingly. Jemalloc can still be selected by setting the ARROW_DEFAULT_MEMORY_POOL environment variable to “jemalloc”. https://arrow.apache.org/blog/2024/10/28/18.0.0-release/
Is there any thought that this problem is going to be addressed in a future release or are we going to have to set this envvar for the foreseeable future? We've been pinning our system to an older version because of this but are getting pressure to upgrade.
There are quite some issues opened on memory leak/memory allocation connected to Arrow and Parquet. I think the best thread to help one understand the topic and to keep open is #44599. I will close others as duplicate. Feel free to comment and I will re-open if we see I was mistaken and the issues are different.
Activity
mthiboust commentedon Apr 7, 2025
Same behavior here. Not sure if
memory-profileris able to correclty track memory allocated bypyarrowmthiboust commentedon Apr 8, 2025
This behavior happens with pyarrow v18 and v19 but not v17. See this memory profile (total memory used given by
btop) with a loop of 5pq.read_table('data.parquet')for pyarrow v19 first, then v18, then v17:The memory is released after each loop iteration for pyarrow v17 only.
Because of this issue, experimenting with
pyarrow&parquetinside jupyter notebooks leads to increasing memory usage until the next kernel restart. It is less problematic for single task scripts that release the memory at the end anyway.mthiboust commentedon Apr 9, 2025
After some investigation, it appears that the difference between versions in the memory profile above is explained by the choice of memory allocator:
jemallocby default for v17 vsmimallocfor v18 and v19.Below is a new memory profile with
pyarrow==19.0.1formimallocon the left andjemallocon the right (loop of 5 iteration of parquet file reading).You can set
jemallocas the default memory allocator using:export ARROW_DEFAULT_MEMORY_POOL=jemallocSee:
timj commentedon Jul 14, 2025
Is there any thought that this problem is going to be addressed in a future release or are we going to have to set this envvar for the foreseeable future? We've been pinning our system to an older version because of this but are getting pressure to upgrade.
AlenkaF commentedon Jul 1, 2026
There are quite some issues opened on memory leak/memory allocation connected to Arrow and Parquet. I think the best thread to help one understand the topic and to keep open is #44599. I will close others as duplicate. Feel free to comment and I will re-open if we see I was mistaken and the issues are different.