8000 Run garbage collection in leak test · matplotlib/matplotlib@34d7183 · GitHub
[go: up one dir, main page]

Skip to content

Commit 34d7183

Browse files
committed
Run garbage collection in leak test
Without it, checking the 'external' memory may indicate a leak even if we've gotten rid of all our objects.
1 parent 44b55df commit 34d7183

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

lib/matplotlib/tests/test_backends_interactive.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,7 @@ def test_blitting_events(env):
508508
# The source of this function gets extracted and run in another process, so it
509509
# must be fully self-contained.
510510
def _test_figure_leak():
511+
import gc
511512
import sys
512513

513514
import psutil
@@ -523,12 +524,14 @@ def _test_figure_leak():
523524
plt.pause(t)
524525
plt.close(fig)
525526
mem = p.memory_info().rss
527+
gc.collect()
526528

527529
for _ in range(5):
528530
fig = plt.figure()
529531
if t:
530532
plt.pause(t)
531533
plt.close(fig)
534+
gc.collect()
532535
growth = p.memory_info().rss - mem
533536

534537
print(growth)

0 commit comments

Comments
 (0)
0