Repository navigation
What's Changed
Features
- Memray now only imports
rich,textual, andjinja2when generating a report that needs them. This reduces the startup time of commands that don't generate reports, likememray runandmemray attach. (#994) - Speed up flame graph generation for large captures by computing the source line, escaped location and the "interesting" flag of each frame only once per report. (#1100)
- Improve allocation tracking performance under multithreaded contention on glibc Linux by using an adaptive mutex for the Tracker lock. (#1035)
- Reduce the time and memory needed to generate temporary-allocation reports from large capture files. (#1009)
- Shrink a capture file down to fit the written data when tracking ends gracefully, dropping any overallocation. Additionally, bound the maximum overallocation to 4 MiB. (#1012)
- Speed up reading uncompressed capture files for sessions where tracking did not end gracefully. (#1008)
- Track individual allocations made by Apache Arrow 25.0 and newer when it uses mimalloc on Linux. (#943)
Bug Fixes
- Thread names were not being properly escaped when generating the HTML output, which could lead to issues if a thread name contained HTML special characters. (#1068)
- Ensure function names, file names, and thread names are never interpreted as markup in Textual TUIs. (#1068)
- Ensure Memray never writes over a file that already exists while compressing, instead writing to a temp file and atomically renaming it to the target file name once compression is complete. This prevents data loss in case of interruptions during the compression process, and ensures we don't overwrite arbitrary files if the target file is a symlink. (#1104)
- Our Linux wheels now bundle curl 8.23.0 and OpenSSL 3.5, instead of curl 8.7.1 and the end-of-life OpenSSL 1.0.2 or 1.1.1 from the manylinux images, which have known vulnerabilities. (#1062)
memray transform csvnow keeps allocations separated by thread instead of merging them across threads, so thetidandthread_namecolumns always identify the thread that performed each allocation. This was always the documented behavior, but the implementation didn't match the documentation. Othermemray transformformats continue to merge allocations across threads. (#996)- HTTPS
DEBUGINFOD_URLSnow work correctly on Debian, Ubuntu, and other non-RHEL distros, andSSL_CERT_FILEandSSL_CERT_DIRenvironment variables are now honored as well. (#1109) - Fix
memray attachwhen Memray is built from source for the latest release candidates of Python 3.15. (#1014) - Fix
realloc(ptr, 0)not being recorded as freeingptrwhen the allocator returnsNULLafter freeing the object, like glibc does, rather than a new distinct pointer, like most other malloc implementations do. (#1097) - Fix a
WorkerFailederror that could occur in thetreereporter if the tree was still being updated when the app began shutting down. (#1107) - Fix a race that could corrupt the capture file when a thread that was already running when tracking started resumes executing Python code while other threads are allocating memory. (#1032)
- Fix a deadlock in Greenlet support in free-threaded Python builds. (#1033)
- Fix the live mode TUI showing only the first thread's allocations until merging was toggled, even though it starts in merged mode. (#1050)
- Fix the live mode TUI sometimes never showing that the tracked process disconnected, or showing an outdated final snapshot, when the process exited while a snapshot was being fetched. (#1075)
- Fix
memray run --livefreezing the tracked program once it has written more than 64 KiB to stderr. (#1098) - Fix
memray statscrashing on captures with no allocations or with only 0- or 1-byte allocations, and its allocation size histogram counting some sizes in a bin whose reported range excluded them. The last bin's upper bound is now exactly the largest allocation size. (#1076) - Treat every directory on
sys.pathwhose name issite-packagesas a site-packages directory for the purposes of deciding whether code came from an installed package. (#1081) - Show a clear error instead of a traceback, and stop leaving empty output files behind, when a report that needs every allocation is requested for an aggregated capture file. (#1084)
- Fix a crash that could occur when tracking with
--trace-python-allocatorsstarted or stopped while other threads were allocating memory, most often in free-threaded Python builds. (#1095) - Use the public
PyEval_SetProfileAllThreadsAPI on Python 3.12, rather than walking the interpreter's thread list ourselves and calling a private CPython function for each thread state. (#1000) - Avoid unnecessary native stack unwinding for object destruction events when tracking object lifetimes. (#1020)
- Prevent unbounded memory allocation when reading native segments from a malformed capture file. (#1005)
- Handle other types of capture file corruption more gracefully. (#1010)
Improved Documentation
- Document the fields in the JSON output of
memray stats, including how thetotal_allocationsandtotal_framesmetadata fields differ fromtotal_num_allocations. (#807)
New Contributors
- @eqbech made their first contribution in #1000
- @KRRT7 made their first contribution in #1020
- @Johnny-Kao made their first contribution in #1035
- @kiri11 made their first contribution in #1044
- @ADAMAMZAR made their first contribution in #1105
- @patrick-immometrica made their first contribution in #1103
- @RTorres1980 made their first contribution in #1094
- @Lotion-3 made their first contribution in #1091
- @mweinelt made their first contribution in #1086
- @Daranton made their first contribution in #1090
- @pcbeingused333 made their first contribution in #1090
- @Vectrain51, @S3DFX-CYBER, @seyung56-hue, and @ers-adam each independently reported the bug fixed by #1068
Full Changelog: v1.20.0...v1.21.0