コード例 #1
0
ファイル: test_memory_leak.py プロジェクト: MaloneQQ/mypaint
def iterations():
    check_garbage()

    max_mem = 0
    max_mem_stable = 0
    max_mem_increasing = 0
    leak = True
    m1 = 0
    for i in range(options.max_iterations):
        yield i
        if options.debug:
            if i == 3:
                check_garbage()
                helpers.record_memory_leak_status()
            if i == 4 or i == 5:
                helpers.record_memory_leak_status(print_diff=True)
        m2 = mem()
        print('iteration %02d/%02d: %d pages used (%+d)' % (
            i + 1,
            options.max_iterations,
            m2,
            m2 - m1))
        m1 = m2
        if m2 > max_mem:
            max_mem = m2
            max_mem_stable = 0
            max_mem_increasing += 1
            if max_mem_increasing == options.required:
                print('maximum was always increasing for', max_mem_increasing,
                      'iterations')
                break
        else:
            max_mem_stable += 1
            max_mem_increasing = 0
            if max_mem_stable == options.required:
                print('maximum was stable for', max_mem_stable, 'iterations')
                leak = False
                break

    check_garbage()

    if leak:
        print('memory leak found')
        sys.exit(LEAK_EXIT_CODE)
    else:
        print('no leak found')
コード例 #2
0
def iterations():
    check_garbage()

    max_mem = 0
    max_mem_stable = 0
    max_mem_increasing = 0
    leak = True
    m1 = 0
    for i in range(options.max_iterations):
        yield i
        if options.debug:
            if i == 3:
                check_garbage()
                helpers.record_memory_leak_status()
            if i == 4 or i == 5:
                helpers.record_memory_leak_status(print_diff=True)
        m2 = mem()
        print('iteration %02d/%02d: %d pages used (%+d)' %
              (i + 1, options.max_iterations, m2, m2 - m1))
        m1 = m2
        if m2 > max_mem:
            max_mem = m2
            max_mem_stable = 0
            max_mem_increasing += 1
            if max_mem_increasing == options.required:
                print('maximum was always increasing for', max_mem_increasing,
                      'iterations')
                break
        else:
            max_mem_stable += 1
            max_mem_increasing = 0
            if max_mem_stable == options.required:
                print('maximum was stable for', max_mem_stable, 'iterations')
                leak = False
                break

    check_garbage()

    if leak:
        print('memory leak found')
        sys.exit(LEAK_EXIT_CODE)
    else:
        print('no leak found')
コード例 #3
0
 def print_memory_leak_cb(self, action):
     helpers.record_memory_leak_status(print_diff = True)
コード例 #4
0
ファイル: drawwindow.py プロジェクト: jana-choi/OpenSource
 def print_memory_leak_cb(self, action):
     helpers.record_memory_leak_status(print_diff=True)