Skip to content

Commit 7f8a247

Browse files
greateggsgregfilmor
authored andcommitted
Tighten leak-test threshold to 10% to actually fail the bug
The previous 90% threshold (0.9 MB/iter against a 1 MB allocation) documented the issue but did not reproduce it: master leaks ~600-765 KB/iter, which the 0.9 MB threshold accepts as passing. Drop the threshold to 10% (104 KB/iter). On the 2026-05-09 verification run with Python 3.14 GIL on linux-aarch64: Without fix (master): ~572-765 KB/iter (FAIL) With fix (this branch): ~-500 B/iter (PASS) Margin is roughly 6x in either direction across .NET 8 and .NET 10, so the threshold cleanly separates buggy from fixed states without being sensitive to GC noise.
1 parent a305127 commit 7f8a247

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

tests/test_method.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -983,9 +983,10 @@ def test_getting_generic_method_binding_does_not_leak_memory(memory_usage_tracki
983983
bytesAllocatedPerIteration = pow(2, 20) # 1MB
984984
bytesLeakedPerIteration = processBytesDelta / iterations
985985

986-
# Allow 90% threshold - this shows the original issue is fixed, which leaks the full allocated bytes per iteration
987-
# Increased from 50% to ensure that it works on Windows with Python >3.13
988-
failThresholdBytesLeakedPerIteration = bytesAllocatedPerIteration * 0.9
986+
# Tight 10% threshold: with the fix the per-iteration leak is essentially
987+
# zero, while the bug retains the bulk of the 1 MB payload (~600 KB/iter
988+
# on 3.14 GIL). 100 KB/iter cleanly distinguishes the two states.
989+
failThresholdBytesLeakedPerIteration = bytesAllocatedPerIteration * 0.1
989990

990991
assert bytesLeakedPerIteration < failThresholdBytesLeakedPerIteration
991992

@@ -1025,8 +1026,8 @@ def test_getting_overloaded_method_binding_does_not_leak_memory(memory_usage_tra
10251026
bytesAllocatedPerIteration = pow(2, 20) # 1MB
10261027
bytesLeakedPerIteration = processBytesDelta / iterations
10271028

1028-
# Allow 90% threshold - this shows the original issue is fixed, which leaks the full allocated bytes per iteration
1029-
failThresholdBytesLeakedPerIteration = bytesAllocatedPerIteration * 0.9
1029+
# Tight 10% threshold; see test_getting_generic_method_binding_does_not_leak_memory.
1030+
failThresholdBytesLeakedPerIteration = bytesAllocatedPerIteration * 0.1
10301031

10311032
assert bytesLeakedPerIteration < failThresholdBytesLeakedPerIteration
10321033

@@ -1068,8 +1069,8 @@ def test_getting_method_overloads_binding_does_not_leak_memory(memory_usage_trac
10681069
bytesAllocatedPerIteration = pow(2, 20) # 1MB
10691070
bytesLeakedPerIteration = processBytesDelta / iterations
10701071

1071-
# Allow 90% threshold - this shows the original issue is fixed, which leaks the full allocated bytes per iteration
1072-
failThresholdBytesLeakedPerIteration = bytesAllocatedPerIteration * 0.9
1072+
# Tight 10% threshold; see test_getting_generic_method_binding_does_not_leak_memory.
1073+
failThresholdBytesLeakedPerIteration = bytesAllocatedPerIteration * 0.1
10731074

10741075
assert bytesLeakedPerIteration < failThresholdBytesLeakedPerIteration
10751076

0 commit comments

Comments
 (0)