memory consumption

Dieter Maurer dieter at handshake.de
Wed Mar 31 11:17:22 EDT 2021


Alexey wrote at 2021-3-31 02:43 -0700:
>среда, 31 марта 2021 г. в 06:54:52 UTC+3, Inada Naoki:
> ...
>> You can get some hints from sys._debugmallocstats(). It prints
>> obmalloc (allocator for small objects) stats to stderr.
>> Try printing stats before and after 1st run, and after 2nd run. And
>> post it in this thread if you can. (no sensible information in the
>> stats).

`glibc` has similar functions to monitor the memory allocation
at the C level: `mallinfo[2]`, `malloc_stats`, `malloc_info`.

The `mallinfo` functions can be called via `ctypes`.
Provided your `glibc` has `mallinfo2`, I recommend its use.

In order to use `malloc_info` from Python, you need
a C extension. I have one implemented via `cython`. Let me know,
if you are interested.


More information about the Python-list mailing list