How does Python handle memory?

I was looking for a database in memory - and I was wondering how Python handles non-connection IOs (and even data); e.g. hashes, sets, etc .; it is a config somewhere, or it is dynamically managed based on resources; Are there "simple" ways to view effect resources on a real program and simulate that performance may differ from hardware settings?

NOTE. If that matters, Redis is the in-memory data store I'm looking at; there is a shell implementation for Redis data types to mimic the data types found in Python.

+4
source share
2 answers

Python allocates all the memory requested by the application. There are not so many politicians. The only problem is when to release the memory. (C) Python immediately frees all memory that is no longer referenced (this is also not configurable). Memory referenced only by itself (i.e. loops) is freed by the garbage collector; It has customizable settings.

It is an operating system solution to write part of the memory to a page file.

+7
source

Not exactly what you are asking for, but Dowser is a Python tool for interactively viewing the memory usage of your running program. Very helpful in understanding memory usage and allocation patterns.

http://www.aminus.net/wiki/Dowser

+1
source

Source: https://habr.com/ru/post/1332599/


All Articles