r1 - 12 Jan 2005 - 22:32:39 - HeikkiToivonenYou are here: OSAF >  Journal Web  >  ContributorNotes > HeikkiToivonenNotes > HeikkiToivonen20050112

Python process size

As part of our PerformanceProject we will need to instrument Chandler, and get all kinds of timing etc. data programmatically out of the running application. Today I started wondering if there is any way to get the amount of memory the application is using from Python. I found one answer so far: the resource module. According to the docs this should give the size of the process+it's children in bytes:

import resource
pages = resource.getrusage(RUSAGE_BOTH).ru_maxrss
total = pages * resource.getpagesize()

Available on Unix only frown

ASPN Python Cookbook also has some material, for Linux: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/286222

Edit | WYSIWYG | Attach | Printable | Raw View | Backlinks: Web, All Webs | History: r1 | More topic actions
 
Open Source Applications Foundation
Except where otherwise noted, this site and its content are licensed by OSAF under an Creative Commons License, Attribution Only 3.0.
See list of page contributors for attributions.