@@ -627,66 +627,6 @@ def test_blitting_events(env):
627
627
assert 0 < ndraws < 5
628
628
629
629
630
- # The source of this function gets extracted and run in another process, so it
631
- # must be fully self-contained.
632
- def _test_figure_leak ():
633
- import gc
634
- import sys
635
-
636
- import psutil
637
- from matplotlib import pyplot as plt
638
- # Second argument is pause length, but if zero we should skip pausing
639
- t = float (sys .argv [1 ])
640
- p = psutil .Process ()
641
-
642
- # Warmup cycle, this reasonably allocates a lot
643
- for _ in range (2 ):
644
- fig = plt .figure ()
645
- if t :
646
- plt .pause (t )
647
- plt .close (fig )
648
- mem = p .memory_info ().rss
649
- gc .collect ()
650
-
651
- for _ in range (5 ):
652
- fig = plt .figure ()
653
- if t :
654
- plt .pause (t )
655
- plt .close (fig )
656
- gc .collect ()
657
- growth = p .memory_info ().rss - mem
658
-
659
- print (growth )
660
-
661
-
662
- # TODO: "0.1" memory threshold could be reduced 10x by fixing tkagg
663
- @pytest .mark .skipif (sys .platform == "win32" ,
664
- reason = "appveyor tests fail; gh-22988 suggests reworking" )
665
- @pytest .mark .parametrize ("env" , _get_testable_interactive_backends ())
666
- @pytest .mark .parametrize ("time_mem" , [(0.0 , 2_000_000 ), (0.1 , 30_000_000 )])
667
- def test_figure_leak_20490 (env , time_mem , request ):
668
- pytest .importorskip ("psutil" , reason = "psutil needed to run this test" )
669
-
670
- # We haven't yet directly identified the leaks so test with a memory growth
671
- # threshold.
672
- pause_time , acceptable_memory_leakage = time_mem
673
- if env ["MPLBACKEND" ] == "wx" :
674
- pytest .skip ("wx backend is deprecated; tests failed on appveyor" )
675
-
676
- if env ["MPLBACKEND" ] == "macosx" :
677
- request .node .add_marker (pytest .mark .xfail (reason = "macosx backend is leaky" ))
678
-
679
- if env ["MPLBACKEND" ] == "tkagg" and sys .platform == "darwin" :
680
- acceptable_memory_leakage += 11_000_000
681
-
682
- result = _run_helper (
683
- _test_figure_leak , str (pause_time ),
684
- timeout = _test_timeout , extra_env = env )
685
-
686
- growth = int (result .stdout )
687
- assert growth <= acceptable_memory_leakage
688
-
689
-
690
630
def _impl_test_interactive_timers ():
691
631
# A timer with <1 millisecond gets converted to int and therefore 0
692
632
# milliseconds, which the mac framework interprets as singleshot.
0 commit comments