From aabe655d185dd99f731eba0da1c55cf03c41bbca Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Fri, 7 Aug 2026 06:37:52 +0300 Subject: [PATCH] gh-75876: Correct the memory use declared by some bigmem tests Measured with a limited address space and the peak RSS of the process: * TupleTest.test_repeat_large_2 keeps 3 tuples of pointers alive, as its siblings do, but declared the count for a 32-bit build. * The md5 tests hash the data and a io.BytesIO() copy of it. * testDecompress4G keeps the data, the compressed and the decompressed bytes alive, and the decompressor grows its output buffer. * test_huge_string_builtins uses 3 times the string size, not 2. * test_large_subn uses a bit more than the 18 times it declared. Co-authored-by: Claude Opus 5 (1M context) --- Lib/test/test_bigmem.py | 2 +- Lib/test/test_hashlib.py | 4 ++-- Lib/test/test_re.py | 2 +- Lib/test/test_tcl.py | 2 +- Lib/test/test_zlib.py | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Lib/test/test_bigmem.py b/Lib/test/test_bigmem.py index 7f53379a952dfc1..3c09cdb86408909 100644 --- a/Lib/test/test_bigmem.py +++ b/Lib/test/test_bigmem.py @@ -901,7 +901,7 @@ def test_repeat_small(self, size): def test_repeat_large(self, size): return self.basic_test_repeat(size) - @bigmemtest(size=_1G - 1, memuse=12) + @bigmemtest(size=_1G - 1, memuse=pointer_size * 3) def test_repeat_large_2(self, size): return self.basic_test_repeat(size) diff --git a/Lib/test/test_hashlib.py b/Lib/test/test_hashlib.py index f0e2d527af26158..253a8f455853f58 100644 --- a/Lib/test/test_hashlib.py +++ b/Lib/test/test_hashlib.py @@ -691,12 +691,12 @@ def test_case_md5_2(self): ) @unittest.skipIf(sys.maxsize < _4G + 5, 'test cannot run on 32-bit systems') - @bigmemtest(size=_4G + 5, memuse=1, dry_run=False) + @bigmemtest(size=_4G + 5, memuse=2, dry_run=False) def test_case_md5_huge(self, size): self.check('md5', b'A'*size, 'c9af2dff37468ce5dfee8f2cfc0a9c6d') @unittest.skipIf(sys.maxsize < _4G - 1, 'test cannot run on 32-bit systems') - @bigmemtest(size=_4G - 1, memuse=1, dry_run=False) + @bigmemtest(size=_4G - 1, memuse=2, dry_run=False) def test_case_md5_uintmax(self, size): self.check('md5', b'A'*size, '28138d306ff1b8281f1a9067e1a1a2b3') diff --git a/Lib/test/test_re.py b/Lib/test/test_re.py index af6e4612dcfaef5..d086fd521e73b59 100644 --- a/Lib/test/test_re.py +++ b/Lib/test/test_re.py @@ -2251,7 +2251,7 @@ def test_large_search(self, size): # The huge memuse is because of re.sub() using a list and a join() # to create the replacement result. - @bigmemtest(size=_2G, memuse=16 + 2) + @bigmemtest(size=_2G, memuse=16 + 3) def test_large_subn(self, size): # Issue #10182: indices were 32-bit-truncated. s = 'a' * size diff --git a/Lib/test/test_tcl.py b/Lib/test/test_tcl.py index 26be4ee0d7afe44..b0458e46c6beced 100644 --- a/Lib/test/test_tcl.py +++ b/Lib/test/test_tcl.py @@ -805,7 +805,7 @@ def test_huge_string_call(self, size): @support.cpython_only @unittest.skipUnless(INT_MAX < PY_SSIZE_T_MAX, "needs UINT_MAX < SIZE_MAX") - @support.bigmemtest(size=INT_MAX + 1, memuse=2, dry_run=False) + @support.bigmemtest(size=INT_MAX + 1, memuse=3, dry_run=False) def test_huge_string_builtins(self, size): tk = self.interp.tk value = '1' + ' ' * size diff --git a/Lib/test/test_zlib.py b/Lib/test/test_zlib.py index ed9d85408159b28..46c84c55c93398d 100644 --- a/Lib/test/test_zlib.py +++ b/Lib/test/test_zlib.py @@ -1090,7 +1090,7 @@ def testEOFError(self): self.assertRaises(EOFError, zlibd.decompress, b"") @support.skip_if_pgo_task - @bigmemtest(size=_4G + 100, memuse=3.3) + @bigmemtest(size=_4G + 100, memuse=4.5) def testDecompress4G(self, size): # "Test zlib._ZlibDecompressor.decompress() with >4GiB input" blocksize = min(10 * 1024 * 1024, size)