enforce icon indicating copy to clipboard operation
enforce copied to clipboard

@runtime_validation leaks refcounts and therefore causes memory leaks

Open itamarst opened this issue 7 years ago • 0 comments

Enforce 0.3.4.

import sys
from typing import List
import enforce


@enforce.runtime_validation
def noop_validated(i: List) -> List:
    return i

def noop(i: List) -> List:
    return i

if __name__ == '__main__':
    mylist = []
    print("Initial refcounts", sys.getrefcount(mylist))
    noop(mylist)
    print("Refcounts after noop():", sys.getrefcount(mylist))
    noop_validated(mylist)
    print("Refcounts after noop_validated():", sys.getrefcount(mylist))

Results:

$ python /tmp/reproducer.py 
Initial refcounts 2
Refcounts after noop(): 2
Refcounts after noop_validated(): 6

itamarst avatar Aug 01 '18 18:08 itamarst