Skip to content

Add a new memleak script that does everything #5360

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Nov 5, 2015
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix units as reported by report_memory
  • Loading branch information
mdboom committed Nov 2, 2015
commit 457fd94240ed55543e71141f7bc292d56a1bef8f
19 changes: 5 additions & 14 deletions lib/matplotlib/cbook.py
Original file line number Diff line number Diff line change
Expand Up @@ -1439,27 +1439,18 @@ def restrict_dict(d, keys):


def report_memory(i=0): # argument may go away
'return the memory consumed by process'
'return the memory, in bytes, consumed by process'
from matplotlib.compat.subprocess import Popen, PIPE
pid = os.getpid()
if sys.platform == 'sunos5':
try:
a2 = Popen('ps -p %d -o osz' % pid, shell=True,
stdout=PIPE).stdout.readlines()
except OSError:
raise NotImplementedError(
"report_memory works on Sun OS only if "
"the 'ps' program is found")
mem = int(a2[-1].strip())
elif sys.platform.startswith('linux'):
if sys.platform.startswith('linux'):
try:
a2 = Popen('ps -p %d -o rss,sz' % pid, shell=True,
stdout=PIPE).stdout.readlines()
except OSError:
raise NotImplementedError(
"report_memory works on Linux only if "
"the 'ps' program is found")
mem = int(a2[1].split()[1])
mem = int(a2[1].split()[1]) * 1024
elif sys.platform.startswith('darwin'):
try:
a2 = Popen('ps -p %d -o rss,vsz' % pid, shell=True,
Expand All @@ -1468,7 +1459,7 @@ def report_memory(i=0): # argument may go away
raise NotImplementedError(
"report_memory works on Mac OS only if "
"the 'ps' program is found")
mem = int(a2[1].split()[0])
mem = int(a2[1].split()[0]) * 1024
elif sys.platform.startswith('win'):
try:
a2 = Popen(["tasklist", "/nh", "/fi", "pid eq %d" % pid],
Expand All @@ -1477,7 +1468,7 @@ def report_memory(i=0): # argument may go away
raise NotImplementedError(
"report_memory works on Windows only if "
"the 'tasklist' program is found")
mem = int(a2.strip().split()[-2].replace(',', ''))
mem = int(a2.strip().split()[-2].replace(',', '')) * 1024
else:
raise NotImplementedError(
"We don't have a memory monitor for %s" % sys.platform)
Expand Down