[Baypiggies] Watching how much memory my Python program is taking up

Phil Plante phil at rentlytics.com
Thu Feb 19 21:43:04 CET 2015


psutil (2.2.1) worked really well for me on OSX and Windows recently.  You
might want to give it a try, if platform compatibility is of any concern.
ᐧ

On Thu, Feb 19, 2015 at 12:32 PM, Minesh Patel <minesh at gmail.com> wrote:

> Along the same lines as Bill mentioned:
>
> proc_data = = open('/proc/%s/status' % os.getpid()).read()
>
> should work
>
> Cheers,
> Minesh
>
> On Thu, Feb 19, 2015 at 12:02 PM, Paul Hoffman <paul.hoffman at gmail.com>
> wrote:
>
>> This could be a good shot, but I'm not sure how to use it to get the
>> current amount of memory used by the Python program. If I do a
>> subprocess.getoutput("cat /proc/sefl/status"), is shows the amount of
>> memory used for "cat", not for the enclosing program.
>>
>> --Paul Hoffman
>>
>> On Thu, Feb 19, 2015 at 9:27 AM, William Deegan <bdbaddog at gmail.com>
>> wrote:
>>
>>> Paul,
>>>
>>> If you only care about linux you can parse /proc/self/status
>>>
>>> -Bill
>>>
>>> On Thu, Feb 19, 2015 at 8:08 AM, Paul Hoffman <paul.hoffman at gmail.com>
>>> wrote:
>>>
>>>> Greetings. I have a Python 3.4 program that will keep eating up memory
>>>> until I tell it to stop; in short, it uses asyncio to launch as many
>>>> coroutines as the machine can handle. I want to determine approximately how
>>>> much memory I am using at this moment so I know when to stop consuming more
>>>> and having the box run out of memory (I already have swapping turned off).
>>>>
>>>> Are there well-known patterns for this? I looked in a bunch of places
>>>> and found nothing, which kinda surprised me. I recognize that it is
>>>> unlikely that there is a cross-OS method for this, but I would be happy
>>>> with just something that says "I'm now taking up a total of 3.7 gig" and I
>>>> can do the "how much is too much" calculation by hand.
>>>>
>>>> Pointers are appreciated.
>>>>
>>>> --Paul Hoffman
>>>>
>>>> _______________________________________________
>>>> Baypiggies mailing list
>>>> Baypiggies at python.org
>>>> To change your subscription options or unsubscribe:
>>>> https://mail.python.org/mailman/listinfo/baypiggies
>>>>
>>>
>>>
>>
>> _______________________________________________
>> Baypiggies mailing list
>> Baypiggies at python.org
>> To change your subscription options or unsubscribe:
>> https://mail.python.org/mailman/listinfo/baypiggies
>>
>
>
>
> --
> Thanks,
> --Minesh
>
> _______________________________________________
> Baypiggies mailing list
> Baypiggies at python.org
> To change your subscription options or unsubscribe:
> https://mail.python.org/mailman/listinfo/baypiggies
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/baypiggies/attachments/20150219/13d9910a/attachment.html>


More information about the Baypiggies mailing list