Bloomberg has open-sourced memray, a memory profiling tool for Python applications. The program monitors memory allocation operations in Python and offers a visual interface for analyzing and optimizing the memory consumption of various code sections, as well as plug-ins written in C/C++. Reports can be generated both interactively and generated in HTML format. It includes a CLI interface for managing profiling and a library that can be used to monitor memory activity in third-party projects. The code is published under the Apache 2.0 license. Operation is only supported on the Linux platform.
Key features:
- Applications: Finding the causes of high memory consumption in applications, finding memory leaks, and identifying code that is doing too many memory allocations.
- Track all function calls in relation to total memory consumption, consumption within the function, and the number of memory allocations. Ability to accurately estimate the call stack.
- Handling calls to C/C++ libraries and accounting for memory consumption in native modules. Support for analyzing projects using numpy and pandas.
- Minimal overhead and negligible impact on the performance of the analyzed application. Ability to disable native code tracking to improve performance.
- The presence of a large number of reports on memory usage, including visual hierarchical and stepped graphs (flame graph).
- The ability to work with threads and analyze memory in the context of individual threads. Both Python threads and native threads such as C++ threads used in C/C++ modules are supported.
- The ability to integrate with pytest and provide pytest annotations that define the memory consumption limits, if exceeded, warnings will be generated during test execution.
Source: opennet.ru