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.
source share