@@ -511,38 +511,38 @@ def _test_figure_leak():
511
511
512
512
import psutil
513
513
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"
516
516
p = psutil .Process ()
517
517
518
518
# Warmup cycle, this reasonably allocates a lot
519
519
for _ in range (2 ):
520
520
fig = plt .figure ()
521
- if t :
522
- plt .pause (t )
521
+ if flush : fig .canvas .flush_events ()
523
522
plt .close (fig )
523
+ if flush : fig .canvas .flush_events ()
524
524
mem = p .memory_info ().rss
525
525
526
526
for _ in range (5 ):
527
527
fig = plt .figure ()
528
- if t :
529
- plt .pause (t )
528
+ if flush : fig .canvas .flush_events ()
530
529
plt .close (fig )
530
+ if flush : fig .canvas .flush_events ()
531
531
growth = p .memory_info ().rss - mem
532
532
533
533
print (growth )
534
534
535
535
536
536
@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 ):
539
539
pytest .importorskip ("psutil" , reason = "psutil needed to run this test" )
540
540
541
541
# We can't yet directly identify the leak
542
542
# so test with a memory growth threshold
543
- acceptable_memory_leakage = 2_000_000
543
+ acceptable_memory_leakage = 3_000_000
544
544
545
- result = _run_helper (_test_figure_leak , time , timeout = _test_timeout , ** env )
545
+ result = _run_helper (_test_figure_leak , flush , timeout = _test_timeout , ** env )
546
546
547
547
growth = int (result .stdout )
548
548
assert growth <= acceptable_memory_leakage
0 commit comments