@@ -55,44 +55,43 @@ def test_open_save_objects_leaks():
5555
5656
5757def _get_mem_usage ():
58- from resource import RUSAGE_SELF , getrusage
58+ from resource import RUSAGE_SELF , getpagesize , getrusage
5959
60- if sys .platform == "darwin" :
61- return int (getrusage (RUSAGE_SELF ).ru_maxrss / 1024 ) # Kb
62- return getrusage (RUSAGE_SELF ).ru_maxrss # Kb
60+ mem = getrusage (RUSAGE_SELF ).ru_maxrss
61+ return mem * getpagesize () / 1024 / 1024
6362
6463
65- @pytest .mark .skipif (sys .platform .lower () == "win32" , reason = "requires Unix or macOS " )
64+ @pytest .mark .skipif (sys .platform .lower () in ( "win32" , "darwin" ), reason = "run only on Linux " )
6665@pytest .mark .skipif (machine ().find ("x86_64" ) == - 1 , reason = "run only on x86_64" )
6766def test_open_to_numpy_mem_leaks ():
6867 import numpy as np
6968
7069 mem_limit = None
7170 im_path = Path ("images/heif/L_10.heif" )
72- for i in range (500 ):
71+ for i in range (1000 ):
7372 heif_file = pillow_heif .open_heif (im_path , convert_hdr_to_8bit = False )
7473 _array = np .asarray (heif_file [0 ]) # noqa
7574 _array = None # noqa
7675 gc .collect ()
7776 mem = _get_mem_usage ()
78- if i < 300 :
77+ if i < 100 :
7978 mem_limit = mem + 1
8079 continue
8180 assert mem <= mem_limit , f"memory usage limit exceeded after { i + 1 } iterations"
8281
8382
84- @pytest .mark .skipif (sys .platform .lower () == "win32" , reason = "requires Unix or macOS " )
83+ @pytest .mark .skipif (sys .platform .lower () in ( "win32" , "darwin" ), reason = "run only on Linux " )
8584@pytest .mark .skipif (machine ().find ("x86_64" ) == - 1 , reason = "run only on x86_64" )
8685def test_nclx_profile_leaks ():
8786 mem_limit = None
8887 im_path = Path ("images/heif_other/cat.hif" )
8988 heif_file = pillow_heif .open_heif (im_path , convert_hdr_to_8bit = False )
90- for i in range (800 ):
89+ for i in range (1000 ):
9190 _nclx = pillow_heif .private .read_color_profile (heif_file [0 ]._handle ) # noqa
9291 _nclx = None # noqa
9392 gc .collect ()
9493 mem = _get_mem_usage ()
95- if i < 300 :
94+ if i < 100 :
9695 mem_limit = mem + 1
9796 continue
9897 assert mem <= mem_limit , f"memory usage limit exceeded after { i + 1 } iterations"
0 commit comments