RSS (Resident Set Size) is a closer approximation of actual physical memory 
consumed by a process. VSZ includes shared libraries and anything else 
required to be mapped in to make the process complete but shared libraries 
are not in physical memory more than once for all processes except the 
writeable data area they may contain.

Presuming Linux or UNIX like system and CPython memory allocation ultimately 
comes down to the library function malloc which is layered over the system 
call sbreak. The malloc library call manages allocation of memory to 
whatever is requesting it such as the CPython interpreter but works from a 
pool for performance efficiency. If it runs out of room it calls the system 
using sbreak to get another chunk. It is possible to reduce the size by 
calling sbreak with a smaller size but malloc must be sure the area given 
back is completely free from use by objects. This was typically never done 
in the past. If malloc frees a lot of space then it will just reuse it on 
the next allocation request. I admit I have not dug into the CPython use of 
malloc reading code to see what it does. What I am saying is the numbers 
reported by system utilities can be misleading specifically if sbreak size 
reduction is not exercised.

Reply via email to