MCPcopy Create free account
hub / github.com/apache/arrow / assert_does_not_leak

Function assert_does_not_leak

python/scripts/test_leak.py:31–47  ·  view source on GitHub ↗
(f, iterations=10, check_interval=1, tolerance=5)

Source from the content-addressed store, hash-verified

29
30
31def assert_does_not_leak(f, iterations=10, check_interval=1, tolerance=5):
32 gc.collect()
33 baseline = memory_profiler.memory_usage()[0]
34 for i in range(iterations):
35 f()
36 if i % check_interval == 0:
37 gc.collect()
38 usage = memory_profiler.memory_usage()[0]
39 diff = usage - baseline
40 print(f"{i}: {diff}\r", end="")
41 if diff > tolerance:
42 raise Exception(f"Memory increased by {diff} megabytes after {i + 1} "
43 "iterations")
44 gc.collect()
45 usage = memory_profiler.memory_usage()[0]
46 diff = usage - baseline
47 print(f"\nMemory increased by {diff} megabytes after {iterations} iterations")
48
49
50def test_leak1():

Callers 4

test_leak1Function · 0.85
test_leak2Function · 0.85
test_leak3Function · 0.85
test_ARROW_8801Function · 0.85

Calls 1

fFunction · 0.85

Tested by

no test coverage detected