The profile_utils Module
Shortcuts to get currently allocated memory in bytes
- mem() int [source]
Returns currently allocated memory using full memory info.
When uss aka “Unique Set Size”, is available then this function returns the value of uss. USS is the memory which is unique to a process and which would be freed if the process was terminated right now.
If uss is unavailable it returns the pss, aka “Proportional Set Size”, is the amount of memory shared with other processes, accounted in a way that the amount is divided evenly between the processes that share it. I.e., if a process has 10 MBs all to itself and 10 MBs shared with another process its PSS will be 15 MBs.
This function might be slower than qmem()
- Returns:
currently allocated memory in bytes
- qmem() int [source]
Quickly return currently allocated memory in bytes. This function returns rss, “Resident Set Size”, this is the non-swapped physical memory a process has used. On UNIX it matches “top“‘s RES column).
- Returns:
currently allocated memory in bytes
- qqmem(pid) int [source]
Quickly return currently allocated memory in bytes given the process id. This function does not call os.getpid() and therefore, might be faster than qmem().
This function returns rss, “Resident Set Size”, this is the non-swapped physical memory a process has used. On UNIX it matches “top“‘s RES column).
- Parameters:
pid¶ –
- Returns:
currently allocated memory in bytes