Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > How to monitor memory usage within Python? (Linux)

Reply
Thread Tools

How to monitor memory usage within Python? (Linux)

 
 
kj
Guest
Posts: n/a
 
      02-24-2010




Is there some standard module for getting info about the process's
memory usage, in a Linux/Unix system?

(I want to avoid hacks that involve, e.g., scraping ps's output.)

Thanks!

~K
 
Reply With Quote
 
 
 
 
MrJean1
Guest
Posts: n/a
 
      02-25-2010
For Linux only

<http://code.activestate.com/recipes/286222/>

/Jean

On Feb 24, 2:35*pm, kj <(E-Mail Removed)> wrote:
> Is there some standard module for getting info about the process's
> memory usage, in a Linux/Unix system?
>
> (I want to avoid hacks that involve, e.g., scraping ps's output.)
>
> Thanks!
>
> ~K


 
Reply With Quote
 
 
 
 
Giampaolo Rodola'
Guest
Posts: n/a
 
      02-25-2010
On 24 Feb, 23:35, kj <(E-Mail Removed)> wrote:
> Is there some standard module for getting info about the process's
> memory usage, in a Linux/Unix system?
>
> (I want to avoid hacks that involve, e.g., scraping ps's output.)
>
> Thanks!
>
> ~K


http://code.google.com/p/psutil

>>> import psutil
>>> p = psutil.Process(7055)
>>> p.cmdline

['/usr/bin/python']
>>> rss, vms = p.get_memory_info()
>>> "Resident memory: %s KB" %(rss / 1024)

'Resident memory: 3768 KB'
>>> "Virtual memory: %s KB" %(vms / 1024)

'Virtual memory: 6176 KB'
>>> p.get_memory_percent()

0.8342


--- Giampaolo
http://code.google.com/p/pyftpdlib/
http://code.google.com/p/psutil/
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
What is the difference between Memory Usage and Heap Usage in my JVMMetrics ? Krist Java 8 02-10-2010 12:44 AM
retrieving CPU Usage and Memory Usage information in JAVA hvt Java 0 03-13-2007 01:09 PM
retrieving CPU Usage and Memory Usage information in JAVA hvt Java 0 03-13-2007 01:07 PM
Need help on memory usage VS PF usage metfan Java 2 10-21-2003 01:58 PM



Advertisments