Ram memory not freed after executing python script on ubuntu system (rmlibre)

Dieter Maurer dieter at handshake.de
Fri May 29 01:20:01 EDT 2020


rmlibre at riseup.net wrote at 2020-5-28 18:56 -0700:
>We just ran into this problem when running our aiootp package's memory
>hard password hashing function (https://github.com/rmlibre/aiootp/). The
>memory was not being cleared after the function finished running but the
>script was still live.

I hope you are aware that Python can do nothing to change this:
the elementary memory management feature provided by operating systems
is a way to increase or decrease the "heap" (there is a different
possibility (memory mapping), but it is efficient only for large chunks
of memory). Python cannot truncate the heap below the last used
memory block. Python would need a "compacting" garbage collection
to ensure that used memory is as tight as possible; then it could
free more aggressively. But, a "compacting" garbage collection would
make life **much** more difficult for extensions (implemented in C);
especially, thousands existing extensions would stop working.

Following the example of the C runtime library, Python manages free
memory internally. This implies that operating system means do not
show exact information about the amount of really used memory
(for the operation system, free memory in the internal memory
management is used).


More information about the Python-list mailing list