Skip to content

Conversation

@maedtb
Copy link
Contributor

@maedtb maedtb commented Jan 18, 2026

The documentation does not say this very prominently, but under the documentation for pyplot.close() (https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.close.html), it states that this needs to happen if figures are not displayed using pyplot.show(), which we, nor the TK wrappers, appear to be doing.

This fixes a warning message about a potential leak that is printed to the console once you have opened quite a few figures.

Steps to reproduce:

  1. Create a concept.
  2. Repeat 20 times: Open the concept's window, open the statistics tab, and then close the concept window.
  3. Look at the OneTrainer console output for a warning message related to this:

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 rcParam figure.max_open_warning). Consider using matplotlib.pyplot.close().

The documentation does not say this very prominently, but under the documentation for `pyplot.close()` (https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.close.html), it states that this needs to happen if figures are not displayed using `pyplot.show()`, which we, nor the TK wrappers, appear to be doing.

This fixes a warning message about a potential leak that is printed to the console once you have opened quite a few figures.

Steps to reproduce:
1. Create many concepts (25?)
2. For each concept, open the concept window, open the statistics tab, close the concept window.
3. Look at the OneTrainer console output for a warning message related to this.
self.bucket_ax.yaxis.label.set_color(self.text_color)

# Close any previous figure handle (if we had one)
if prev_bucket_fig is not None:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can this ever happen?
isn't this function only called once during initialization of the window?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants