8000 TST: Add test for layoutgrid memory leak · matplotlib/matplotlib@fb07329 · GitHub
[go: up one dir, main page]

Skip to content

Commit fb07329

Browse files
committed
TST: Add test for layoutgrid m 8000 emory leak
1 parent 544d8ce commit fb07329

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)
0