Skip to content

Commit c98f30e

Browse files
committed
gh-152190: Fix memory checking failure in test_strip_removed_large_file_with_dd_no_sig
Remove the overly restrictive `allowed_memory` override (200 KiB) in `test_strip_removed_large_file_with_dd_no_sig` to prevent a memory checking failure. Additionally, redefine the global baseline allowed memory as a 10x multiplier of the default buffer size to ensure it scales safely relative to the underlying platform.
1 parent aec0aed commit c98f30e

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

Lib/test/test_zipfile64.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import time
1616
import tracemalloc
1717
import sys
18+
import io
1819
import unittest.mock as mock
1920

2021
from tempfile import TemporaryFile
@@ -100,8 +101,10 @@ def setUp(self):
100101
# It will contain enough copies of self.data to reach about 8 GiB.
101102
self.datacount = 8*1024**3 // len(self.data)
102103

103-
# memory usage should not exceed 10 MiB
104-
self.allowed_memory = 10*1024**2
104+
# Memory usage should not exceed the default buffer size too
105+
# much (10x as threshold)
106+
self.allowed_memory = max(
107+
zipfile._REPACK_CHUNK_SIZE * 10, io.DEFAULT_BUFFER_SIZE * 10)
105108

106109
def _write_large_file(self, fh):
107110
next_time = time.monotonic() + _PRINT_WORKING_MSG_INTERVAL
@@ -201,7 +204,6 @@ def test_strip_removed_large_file_with_dd_no_sig(self):
201204
large file without causing a memory issue."""
202205
# Reduce data scale for this test, as it's especially slow...
203206
self.datacount = 30*1024**2 // len(self.data)
204-
self.allowed_memory = 200*1024
205207

206208
# Try the temp file. If we do TESTFN2, then it hogs
207209
# gigabytes of disk space for the duration of the test.

0 commit comments

Comments
 (0)