nicegui
nicegui copied to clipboard
Memory leak in `ui.line_plot`?
The NiceGUI documentation at https://nicegui.io is written with NiceGUI itself. So it's a good testbed to see how well the lib performs with a lot of visitors. One thing we see quite regular is this error message:
/usr/local/lib/python3.10/site-packages/nicegui/elements/plot.py:18: RuntimeWarning: More than 20 figures have been opened. Figures created through the pyplot interface (
matplotlib.pyplot.figure
) are retained until explicitly closed and may consume too much memory. (To control this warning, see the rcParamfigure.max_open_warning
). Consider usingmatplotlib.pyplot.close()
.
When looking at the code, the ui.plot
seems to be ok. By default figures are closed when their context is exited. But with ui.line_plot
new data can be added to the plot. Could this be the root cause of the warning?