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.
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.