chiark / gitweb /
m.plots: matplotlib otherwise keeps everything in memory.
authorVladimír Vondruš <mosra@centrum.cz>
Wed, 16 May 2018 10:31:41 +0000 (12:31 +0200)
committerVladimír Vondruš <mosra@centrum.cz>
Wed, 16 May 2018 10:31:41 +0000 (12:31 +0200)
Huh.

pelican-plugins/m/plots.py

index 173ca76de1d324d5d4e4a602f8fe66c1bbe50bea..1d09cf97239e3429f5091b22e1b8f7f168121c8e 100644 (file)
@@ -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())