[Pythonmac-SIG] Finding the memory usage of a Python process
christopher.e.kees at usace.army.mil
Wed Apr 16 18:43:31 CEST 2008
I have been using an approach like Gary's below, but I just noticed
that it can't
calculate the memory correctly once the resident size gets over about
4G. The 'top'
command seems correct but not 'ps'.
On Apr 15, 2008, at 2:06 PM, Gary Bernhardt wrote:
> On 4/15/08, Konrad Hinsen <konrad.hinsen at laposte.net> wrote:
>> I am trying to obtain the amount of memory that my Python process
>> uses from inside the Python program using resource.getrusage().
>> this works fine under Linux, on the Mac I always get 0 for the
>> usage (the time information seems credible though).
>> Does anyone have another idea for monitoring memory usage on the
> I needed this as well but didn't find a clean way to do it.
> Eventually I gave up and shelled out to "ps" with something like this:
> cmd = 'ps %i -o rss' % pid
> pipe = subprocess.Popen(cmd, stdout=subprocess.PIPE,
> mem_usage = int(pipe.readlines())
> Pythonmac-SIG maillist - Pythonmac-SIG at python.org
More information about the Pythonmac-SIG