8000 tune memory leak test · QuLogic/matplotlib@2829677 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2829677

Browse files
tune memory leak test
1 parent e6e4cad commit 2829677

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

lib/matplotlib/tests/test_backends_interactive.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -511,38 +511,38 @@ def _test_figure_leak():
511511

512512
import psutil
513513
from matplotlib import pyplot as plt
514-
# Second argument is pause length, but if zero we should skip pausing
515-
t = float(sys.argv[1])
514+
515+
flush = sys.argv[1] == "yes"
516516
p = psutil.Process()
517517

518518
# Warmup cycle, this reasonably allocates a lot
519519
for _ in range(2):
520520
fig = plt.figure()
521-
if t:
522-
plt.pause(t)
521+
if flush: fig.canvas.flush_events()
523522
plt.close(fig)
523+
if flush: fig.canvas.flush_events()
524524
mem = p.memory_info().rss
525525

526526
for _ in range(5):
527527
fig = plt.figure()
528-
if t:
529-
plt.pause(t)
528+
if flush: fig.canvas.flush_events()
530529
plt.close(fig)
530+
if flush: fig.canvas.flush_events()
531531
growth = p.memory_info().rss - mem
532532

533533
print(growth)
534534

535535

536536
@pytest.mark.parametrize("env", _get_testable_interactive_backends())
537-
@pytest.mark.parametrize("time", ["0.0", "0.1"])
538-
def test_figure_leak_20490(env, time):
537+
@pytest.mark.parametrize("flush", ["no", "yes"])
538+
def test_figure_leak_20490(env, flush):
539539
pytest.importorskip("psutil", reason="psutil needed to run this test")
540540

541541
# We can't yet directly identify the leak
542542
# so test with a memory growth threshold
543-
acceptable_memory_leakage = 2_000_000
543+
acceptable_memory_leakage = 3_000_000
544544

545-
result = _run_helper(_test_figure_leak, time, timeout=_test_timeout, **env)
545+
result = _run_helper(_test_figure_leak, flush, timeout=_test_timeout, **env)
546546

547547
growth = int(result.stdout)
548548
assert growth <= acceptable_memory_leakage

0 commit comments

Comments
 (0)
0