How to monitor memory usage within Python? (Linux)

K

kj

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
 
G

Giampaolo Rodola'

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/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top