Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit eb19435

Browse files
authored
Merge pull request #25868 from greglucas/layoutgrid-leak-test
TST: Add test for layoutgrid memory leak
2 parents 072e8f3 + fb07329 commit eb19435

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

lib/matplotlib/tests/test_constrainedlayout.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import gc
12
import numpy as np
23
import pytest
34

@@ -678,3 +679,16 @@ def test_constrained_toggle():
678679
assert not fig.get_constrained_layout()
679680
fig.set_constrained_layout(True)
680681
assert fig.get_constrained_layout()
682+
683+
684+
def test_layout_leak():
685+
# Make sure there aren't any cyclic references when using LayoutGrid
686+
# GH #25853
687+
fig = plt.figure(constrained_layout=True, figsize=(10, 10))
688+
fig.add_subplot()
689+
fig.draw_without_rendering()
690+
plt.close("all")
691+
del fig
692+
gc.collect()
693+
assert not any(isinstance(obj, mpl._layoutgrid.LayoutGrid)
694+
for obj in gc.get_objects())

0 commit comments

Comments
 (0)