This module queries process memory allocation metrics from the operating system. It provides a platform independent layer to get the amount of virtual and physical memory allocated to the Python process.

Different mechanisms are implemented: Either the process stat file is read (Linux), the ps command is executed (BSD/OSX/Solaris) or the resource module is queried (Unix fallback). On Windows try to use the win32 module if available. If all fails, return 0 for each attribute.

Windows without the win32 module is not supported.

>>> from pympler.process import ProcessMemoryInfo
>>> pmi = ProcessMemoryInfo()
>>> print ("Virtual size [Byte]: " + str(pmi.vsz)) 
Virtual size [Byte]: ...


class pympler.process._ProcessMemoryInfo

Stores information about various process-level memory metrics. The virtual size is stored in attribute vsz, the physical memory allocated to the process in rss, and the number of (major) pagefaults in pagefaults. On Linux, data_segment, code_segment, shared_segment and stack_segment contain the number of Bytes allocated for the respective segments. This is an abstract base class which needs to be overridden by operating system specific implementations. This is done when importing the module.


Refresh the information using platform instruments. Returns true if this operation yields useful values on the current platform.


Convenience function to check if the current platform is supported by this module.