Revision: 6513
Updated Code
at May 26, 2008 23:11 by fnl
Updated Code
"""fnl.core.memory module Trivial, but working code to get the memory usage of the current process where the pid is retrieved using os.getpid() and the memory usage is read from the unix command ps. """ import os __version__ = "1.0" __author__ = "Florian Leitner" def mem(size="rss"): """Generalization; memory sizes: rss, rsz, vsz.""" return int(os.popen('ps -p %d -o %s | tail -1' % (os.getpid(), size)).read()) def rss(): """Return ps -o rss (resident) memory in kB.""" return mem("rss") def rsz(): """Return ps -o rsz (resident + text) memory in kB.""" return mem("rsz") def vsz(): """Return ps -o vsz (virtual) memory in kB.""" return mem("vsz")
Revision: 6512
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at May 26, 2008 23:03 by fnl
Initial Code
"""fnl.core.memory module Trivial, but working code to get the memory usage of the current process where the pid is retrieved using os.getpid() and the memory usage is read from the unix command ps. Copyright (c) 2007 Florian Leitner. All rights reserved. """ import os __version__ = "1.0" __author__ = "Florian Leitner" def mem(size="rss"): """Generalization; memory sizes: rss, rsz, vsz.""" return int(os.popen('ps -p %d -o %s | tail -1' % (os.getpid(), size)).read()) def rss(): """Return ps -o rss (resident) memory in kB.""" return mem("rss") def rsz(): """Return ps -o rsz (resident + text) memory in kB.""" return mem("rsz") def vsz(): """Return ps -o vsz (virtual) memory in kB.""" return mem("vsz")
Initial URL
Initial Description
Initial Title
get memory usage of current process on unix
Initial Tags
textmate, python
Initial Language
Python