From: Vladimír Vondruš Date: Wed, 16 May 2018 10:31:41 +0000 (+0200) Subject: m.plots: matplotlib otherwise keeps everything in memory. X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~cjwatson/git?a=commitdiff_plain;h=c7e8356e5239100fc15d589a919bec34130e6e42;p=blog.git m.plots: matplotlib otherwise keeps everything in memory. Huh. --- diff --git a/pelican-plugins/m/plots.py b/pelican-plugins/m/plots.py index 173ca76d..1d09cf97 100644 --- a/pelican-plugins/m/plots.py +++ b/pelican-plugins/m/plots.py @@ -214,6 +214,7 @@ class Plot(rst.Directive): fig.patch.set_visible(False) # hide the white background imgdata = io.StringIO() fig.savefig(imgdata, format='svg') + plt.close() # otherwise it consumes a lot of memory in autoreload mode # Patch the rendered output: remove preable and hardcoded size imgdata = _patch_src.sub(_patch_dst, imgdata.getvalue())