def test_refcount_pyobj(self): from pypy.rpython.lltypesystem.lloperation import llop def prob_with_pyobj(b): return 3, b def collect(): llop.gc__collect(lltype.Void) f = self.getcompiled(prob_with_pyobj, [object]) c = self.getcompiled(collect, []) from sys import getrefcount as g obj = None before = g(obj) f(obj) f(obj) f(obj) f(obj) f(obj) c() c() c() c() c() after = g(obj) assert abs(before - after) < 5
def fn(): from pypy.rlib import rgc rgc.set_max_heap_size(500000) s1 = s2 = s3 = None try: s1 = g(10000) s2 = g(100000) s3 = g(1000000) except MemoryError: pass return (s1 is not None) + (s2 is not None) + (s3 is not None)
def test_refcount_pyobj(): def prob_with_pyobj(b): return 3, b f = compile(prob_with_pyobj, [object]) from sys import getrefcount as g obj = None before = g(obj) f(obj) after = g(obj) assert before == after
def f(): s.dels = 0 for i in range(10): g() llop.gc__collect(lltype.Void) return s.dels