File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ 2011-02-05 Add cbook memory monitoring for Windows, using
2+ tasklist. - EF
3+
142011-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
Original file line number Diff line number Diff line change @@ -1233,7 +1233,7 @@ def restrict_dict(d, keys):
12331233
12341234def 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'
You can’t perform that action at this time.
0 commit comments