Example #1
0
def test_base_static_memory_leak_check():
    # Make sure calling this monitoring function doesn't cause a memory
    # leak on it own
    static_mem = OS.get_static_memory_usage()
    static_mem2 = OS.get_static_memory_usage()

    static_leak = static_mem2 - static_mem
    assert static_leak == 0
Example #2
0
def check_memory_leak(fn):
    dynamic_mem_start = OS.get_dynamic_memory_usage()
    static_mem_start = OS.get_static_memory_usage()

    fn()

    # TODO: force garbage collection on pypy

    static_mem_end = OS.get_static_memory_usage()
    dynamic_mem_end = OS.get_dynamic_memory_usage()

    static_leak = static_mem_end - static_mem_start
    dynamic_leak = dynamic_mem_end - dynamic_mem_start
    assert static_leak == 0
    assert dynamic_leak == 0