As quick update (in case anyone runs into this thread because of google):
Making sure you’re using the Renderer lock got rid of the problem for me completely. Memory usage was still pretty high, but now the app wasn’t completely crashing. It even sustained a mild reddit hug of death.
For the long term though:
- I adapted my code to use
plotly
instead ofmatplotlib
to take some of the edge off and just have the browser do most of the work. Plus you get to make the plots interactive. - Do garbage collection after each run of the script
These measures lowered my memory usage from ~50% to ~12.5%