BHoM / LadybugTools_Toolkit

GNU Lesser General Public License v3.0
2 stars 2 forks source link

Change backend for matplotlib for bhom/wrapped/plot methods #241

Closed Tom-Kingstone closed 3 weeks ago

Tom-Kingstone commented 1 month ago

Description:

An issue with memory usage came up when a plot method was used in a loop to generate a lot of images at once, leading to a memory leak and the program running the python exe to crash. The culprit for the memory leak is matplotlib's GUI implementation, where any figures that aren't shown (using a window) get stored in memory, even when plt.close() is called. The solution is to use one of matplotlib's GUI-less backends, and as we are creating pngs, the backend should be "Agg" (See the documentation).

This will only be done for the bhom/wrapped/plot methods, as they are expected to be used via command line and save the image (or print it as a base64 string) rather than displayed via GUI.