Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 053b70b

Browse files
committed
cbook.report_memory: add Windows support via "tasklist"
svn path=/trunk/matplotlib/; revision=8947
1 parent acd19a1 commit 053b70b

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

CHANGELOG

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
2011-02-05 Add cbook memory monitoring for Windows, using
2+
tasklist. - EF
3+
14
2011-02-05 Speed up Normalize and LogNorm by using in-place
25
operations and by using float32 for float32 inputs
36
and for ints of 2 bytes or shorter; based on

lib/matplotlib/cbook.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1233,7 +1233,7 @@ def restrict_dict(d, keys):
12331233

12341234
def report_memory(i=0): # argument may go away
12351235
'return the memory consumed by process'
1236-
from subprocess import Popen, PIPE
1236+
from subprocess import Popen, PIPE, check_output
12371237
pid = os.getpid()
12381238
if sys.platform=='sunos5':
12391239
a2 = Popen('ps -p %d -o osz' % pid, shell=True,
@@ -1247,7 +1247,12 @@ def report_memory(i=0): # argument may go away
12471247
a2 = Popen('ps -p %d -o rss,vsz' % pid, shell=True,
12481248
stdout=PIPE).stdout.readlines()
12491249
mem = int(a2[1].split()[0])
1250-
1250+
elif sys.platform.startswith('win'):
1251+
a2 = check_output(["tasklist", "/nh", "/fi", "pid eq %d" % pid])
1252+
mem = int(a2.strip().split()[-2].replace(',',''))
1253+
else:
1254+
raise NotImplementedError(
1255+
"We don't have a memory monitor for %s" % sys.platform)
12511256
return mem
12521257

12531258
_safezip_msg = 'In safezip, len(args[0])=%d but len(args[%d])=%d'

0 commit comments

Comments
 (0)