Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Closed
Labels
Milestone
Description
In master and in 1.5.1, the new C++ contour routine has a massive memory leak; the 'legacy' mode does not. The following script illustrates this; run it as-is and then with the 'legacy' kwarg uncommented for comparison. (The script is long only because it seemsreport_memory
has been removed fromcbook
. Unless it has simply been moved elsewhere or renamed, we need to bring it back.)
importnumpyasnpimportmatplotlibmatplotlib.use('agg')importmatplotlib.pyplotasplt# from matplotlib.cbook import report_memoryimportos,sysdefreport_memory(i=0):# argument may go away'return the memory consumed by process'frommatplotlib.compat.subprocessimportPopen,PIPEpid=os.getpid()ifsys.platform=='sunos5':try:a2=Popen('ps -p %d -o osz'%pid,shell=True,stdout=PIPE).stdout.readlines()exceptOSError:raiseNotImplementedError("report_memory works on Sun OS only if ""the 'ps' program is found")mem=int(a2[-1].strip())elifsys.platform.startswith('linux'):try:a2=Popen('ps -p %d -o rss,sz'%pid,shell=True,stdout=PIPE).stdout.readlines()exceptOSError:raiseNotImplementedError("report_memory works on Linux only if ""the 'ps' program is found")mem=int(a2[1].split()[1])elifsys.platform.startswith('darwin'):try:a2=Popen('ps -p %d -o rss,vsz'%pid,shell=True,stdout=PIPE).stdout.readlines()exceptOSError:raiseNotImplementedError("report_memory works on Mac OS only if ""the 'ps' program is found")mem=int(a2[1].split()[0])elifsys.platform.startswith('win'):try:a2=Popen(["tasklist","/nh","/fi","pid eq %d"%pid],stdout=PIPE).stdout.read()exceptOSError:raiseNotImplementedError("report_memory works on Windows only if ""the 'tasklist' program is found")mem=int(a2.strip().split()[-2].replace(',',''))else:raiseNotImplementedError("We don't have a memory monitor for %s"%sys.platform)returnmemnp.random.seed(0)z=np.random.randn(500,100)foriinrange(200):fig,ax=plt.subplots()ax.contourf(z)# , corner_mask='legacy')fig.savefig('temp.png')plt.close(fig)ifi%10==0:print(i,report_memory(i))