def f(): p = lltype.malloc(A, flavor='raw') p.value = 123 llop.gc__collect(lltype.Void) res = p.value lltype.free(p, flavor='raw') return res
def f(): for i in range(10): s = lltype.malloc(S) l1.append(s) l2.append(s) if i < 3: l3.append(s) l4.append(s) # We cheat here and only read the table which we later on # process ourselves, otherwise this test takes ages llop.gc__collect(lltype.Void) tb = rgc._heap_stats() a = 0 nr = 0 b = 0 c = 0 d = 0 e = 0 for i in range(len(tb)): if tb[i].count == 10: a += 1 nr = i if tb[i].count > 50: d += 1 for i in range(len(tb)): if tb[i].count == 4: b += 1 c += tb[i].links[nr] e += tb[i].size return d * 1000 + c * 100 + b * 10 + a
def f(): o = gethidden(10) llop.gc__collect(lltype.Void) for i in range(1000): # overwrite freed memory overwrite(lltype.malloc(A), i) a = reveal(o) return a.value
def f(): for i in range(10): s = lltype.malloc(S) l1.append(s) l2.append(s) if i < 3: l3.append(s) l4.append(s) # We cheat here and only read the table which we later on # process ourselves, otherwise this test takes ages llop.gc__collect(lltype.Void) tb = rgc._heap_stats() a = 0 nr = 0 b = 0 c = 0 d = 0 e = 0 for i in range(len(tb)): if tb[i].count == 10: a += 1 nr = i if tb[i].count > 50: d += 1 for i in range(len(tb)): if tb[i].count == 4: b += 1 c += tb[i].links[nr] e += tb[i].size return d * 1000 + c * 100 + b * 10 + a
def f(): ref = g() llop.gc__collect(lltype.Void, 1) b = ref() assert b is not None b.x = 101 return ref() is b
def f(): ref = g() llop.gc__collect(lltype.Void, 1) b = ref() assert b is not None b.x = 101 return ref() is b
def g(): a = A() a.x = 5 wr = weakref.ref(a) llop.gc__collect(lltype.Void) # make everything old assert wr() is not None assert a.x == 5 return wr
def concat(j, dummy): lst = [] for i in range(j): lst.append(str(i)) result = len("".join(lst)) if we_are_translated(): llop.gc__collect(lltype.Void, 0) return result
def g(): a = A() a.x = 5 wr = weakref.ref(a) llop.gc__collect(lltype.Void) # make everything old assert wr() is not None assert a.x == 5 return wr
def concat(j, dummy): lst = [] for i in range(j): lst.append(str(i)) result = len("".join(lst)) if we_are_translated(): llop.gc__collect(lltype.Void, 0) return result
def concat(j): lst = [] for i in range(j): lst.append(str(i)) result = len("".join(lst)) if we_are_translated(): # can't call llop.gc__collect directly llop.gc__collect(lltype.Void) return result
def g(): a = A() assert rgc.pin(a) a.x = 100 wr = weakref.ref(a) llop.gc__collect(lltype.Void) assert wr() is not None assert a.x == 100 return wr
def concat(j): lst = [] for i in range(j): lst.append(str(i)) result = len("".join(lst)) if we_are_translated(): # can't call llop.gc__collect directly llop.gc__collect(lltype.Void) return result
def f(x): a = A() i = 0 while i < x: i += 1 a = A() llop.gc__collect(lltype.Void) llop.gc__collect(lltype.Void) return b.num_deleted
def f(x): a = A() i = 0 while i < x: i += 1 a = A() llop.gc__collect(lltype.Void) llop.gc__collect(lltype.Void) return b.num_deleted
def g(): a = A() assert rgc.pin(a) a.x = 100 wr = weakref.ref(a) llop.gc__collect(lltype.Void) assert wr() is not None assert a.x == 100 return wr
def f(): s.a_dels = 0 s.b_dels = 0 A() B() C() A() B() C() llop.gc__collect(lltype.Void) return s.a_dels * 10 + s.b_dels
def f(): a = A() ref = weakref.ref(a) result = ref() is a ref = g() llop.gc__collect(lltype.Void) result = result and (ref() is None) # check that a further collection is fine llop.gc__collect(lltype.Void) result = result and (ref() is None) return result
def f(): s.a_dels = 0 s.b_dels = 0 A() B() C() A() B() C() llop.gc__collect(lltype.Void) return s.a_dels * 10 + s.b_dels
def f(): a = A() ref = weakref.ref(a) result = ref() is a ref = g() llop.gc__collect(lltype.Void) result = result and (ref() is None) # check that a further collection is fine llop.gc__collect(lltype.Void) result = result and (ref() is None) return result
def f(): a2 = A() a3 = A() id1 = compute_unique_id(a1) id2 = compute_unique_id(a2) id3 = compute_unique_id(a3) llop.gc__collect(lltype.Void) error = 0 if id1 != compute_unique_id(a1): error += 1 if id2 != compute_unique_id(a2): error += 2 if id3 != compute_unique_id(a3): error += 4 return error
def f(): a2 = A() a3 = A() id1 = compute_unique_id(a1) id2 = compute_unique_id(a2) id3 = compute_unique_id(a3) llop.gc__collect(lltype.Void) error = 0 if id1 != compute_unique_id(a1): error += 1 if id2 != compute_unique_id(a2): error += 2 if id3 != compute_unique_id(a3): error += 4 return error
def f(): ref = g() llop.gc__collect(lltype.Void, 1) # start a major cycle # at this point the stack is scanned, and the weakref points # to an object not found, but still reachable: b = ref() llop.debug_print(lltype.Void, b) assert b is not None llop.gc__collect(lltype.Void) # finish the major cycle # assert does not crash, because 'b' is still kept alive b.x = 42 return ref() is b
def finalizer_trigger(self): while True: a = self.next_dead() if a is None: break llop.gc__collect(lltype.Void) b.num_deleted += 1 if isinstance(a, C): b.num_deleted_c += 1 else: C() C()
def finalizer_trigger(self): while True: a = self.next_dead() if a is None: break llop.gc__collect(lltype.Void) b.num_deleted += 1 if isinstance(a, C): b.num_deleted_c += 1 else: C() C()
def f(): ref = g() llop.gc__collect(lltype.Void, 1) # start a major cycle # at this point the stack is scanned, and the weakref points # to an object not found, but still reachable: b = ref() llop.debug_print(lltype.Void, b) assert b is not None llop.gc__collect(lltype.Void) # finish the major cycle # assert does not crash, because 'b' is still kept alive b.x = 42 return ref() is b
def f(): t1 = B() t1.x = 42 static.p = t1 x = 20 all = [None] * x i = 0 while i < x: # enough to cause a minor collect all[i] = [i] * i i += 1 i = static.p.x llop.gc__collect(lltype.Void) return static.p.x + i
def f(x): a = A() a.foo = x ref = weakref.ref(a) all = [None] * x i = 0 while i < x: all[i] = [i] * i i += 1 assert ref() is a llop.gc__collect(lltype.Void) assert ref() is a return a.foo + len(all)
def f(): t1 = B() t1.x = 42 static.p = t1 x = 20 all = [None] * x i = 0 while i < x: # enough to cause a minor collect all[i] = [i] * i i += 1 i = static.p.x llop.gc__collect(lltype.Void) return static.p.x + i
def f(x): a = A() a.foo = x ref = weakref.ref(a) all = [None] * x i = 0 while i < x: all[i] = [i] * i i += 1 assert ref() is a llop.gc__collect(lltype.Void) assert ref() is a return a.foo + len(all)
def f(): x = 20 # for GenerationGC, enough for a minor collection a = A() a.foo = x ref = weakref.ref(a) all = [None] * x i = 0 while i < x: all[i] = [i] * i i += 1 assert ref() is a llop.gc__collect(lltype.Void) assert ref() is a return a.foo + len(all)
def f(x, y): persistent_a1 = A() persistent_a2 = A() i = 0 while i < x: i += 1 a = A() persistent_a3 = A() persistent_a4 = A() llop.gc__collect(lltype.Void) llop.gc__collect(lltype.Void) b.bla = persistent_a1.id + persistent_a2.id + persistent_a3.id + persistent_a4.id print b.num_deleted_c return b.num_deleted
def f(): x = 20 # for GenerationGC, enough for a minor collection a = A() a.foo = x ref = weakref.ref(a) all = [None] * x i = 0 while i < x: all[i] = [i] * i i += 1 assert ref() is a llop.gc__collect(lltype.Void) assert ref() is a return a.foo + len(all)
def f(x, y): persistent_a1 = A() persistent_a2 = A() i = 0 while i < x: i += 1 a = A() persistent_a3 = A() persistent_a4 = A() llop.gc__collect(lltype.Void) llop.gc__collect(lltype.Void) b.bla = persistent_a1.id + persistent_a2.id + persistent_a3.id + persistent_a4.id print b.num_deleted_c return b.num_deleted
def f(x, y): persistent_a1 = A() persistent_a2 = A() i = 0 while i < x: i += 1 a = A() persistent_a3 = A() persistent_a4 = A() llop.gc__collect(lltype.Void) llop.gc__collect(lltype.Void) b.bla = persistent_a1.id + persistent_a2.id + persistent_a3.id + persistent_a4.id # NB print would create a static root! llop.debug_print(lltype.Void, b.num_deleted_c) return b.num_deleted
def f(x, y): persistent_a1 = A() persistent_a2 = A() i = 0 while i < x: i += 1 a = A() persistent_a3 = A() persistent_a4 = A() llop.gc__collect(lltype.Void) llop.gc__collect(lltype.Void) b.bla = persistent_a1.id + persistent_a2.id + persistent_a3.id + persistent_a4.id # NB print would create a static root! llop.debug_print(lltype.Void, b.num_deleted_c) return b.num_deleted
def f(x): a = A() llop.gc__collect(lltype.Void) # 'a' is old, 'ref' is young ref = weakref.ref(a) # now trigger a minor collection all = [None] * x i = 0 while i < x: all[i] = [i] * i i += 1 # now 'a' is old, but 'ref' did not move assert ref() is a llop.gc__collect(lltype.Void) # now both 'a' and 'ref' have moved return ref() is a
def f(x): a = A() llop.gc__collect(lltype.Void) # 'a' is old, 'ref' is young ref = weakref.ref(a) # now trigger a minor collection all = [None] * x i = 0 while i < x: all[i] = [i] * i i += 1 # now 'a' is old, but 'ref' did not move assert ref() is a llop.gc__collect(lltype.Void) # now both 'a' and 'ref' have moved return ref() is a
def f(x): A() i = 0 while i < x: i += 1 A() llop.gc__collect(lltype.Void) llop.gc__collect(lltype.Void) llop.gc__collect(lltype.Void) llop.gc__collect(lltype.Void) return b.num_deleted_1 + b.num_deleted_2 * 1000
def f(x): A() i = 0 while i < x: i += 1 A() llop.gc__collect(lltype.Void) llop.gc__collect(lltype.Void) llop.gc__collect(lltype.Void) llop.gc__collect(lltype.Void) return b.num_deleted_1 + b.num_deleted_2 * 1000
def f(_): i = 0 while i < len(examples): input, components, strict = examples[i] build_example(input) while state.time < len(letters): from rpython.rlib.debug import debug_print debug_print("STATE.TIME:", state.time) state.progress = False llop.gc__collect(lltype.Void) if not state.progress: break state.time += 1 # summarize the finalization order lst = [] for c in letters: lst.append('%s:%d' % (c, age_of(c))) summary = ', '.join(lst) # check that all instances have been finalized if -1 in state.age: return error(i, summary, "not all instances finalized") # check that if a -> b and a and b are not in the same # strong component, then a is finalized strictly before b for c, d in strict: if age_of(c) >= age_of(d): return error( i, summary, "%s should be finalized before %s" % (c, d)) # check that two instances in the same strong component # are never finalized during the same collection for component in components: seen = {} for c in component: age = age_of(c) if age in seen: d = seen[age] return error( i, summary, "%s and %s should not be finalized" " at the same time" % (c, d)) seen[age] = c i += 1 return "ok"
def f(_): i = 0 while i < len(examples): input, components, strict = examples[i] build_example(input) while state.time < len(letters): from rpython.rlib.debug import debug_print debug_print("STATE.TIME:", state.time) state.progress = False llop.gc__collect(lltype.Void) if not state.progress: break state.time += 1 # summarize the finalization order lst = [] for c in letters: lst.append('%s:%d' % (c, age_of(c))) summary = ', '.join(lst) # check that all instances have been finalized if -1 in state.age: return error(i, summary, "not all instances finalized") # check that if a -> b and a and b are not in the same # strong component, then a is finalized strictly before b for c, d in strict: if age_of(c) >= age_of(d): return error(i, summary, "%s should be finalized before %s" % (c, d)) # check that two instances in the same strong component # are never finalized during the same collection for component in components: seen = {} for c in component: age = age_of(c) if age in seen: d = seen[age] return error(i, summary, "%s and %s should not be finalized" " at the same time" % (c, d)) seen[age] = c i += 1 return "ok"
def f(x): a = A() i = 0 while i < x: i += 1 a = A() llop.gc__collect(lltype.Void) llop.gc__collect(lltype.Void) aid = b.a.id b.a = None # check that __del__ is not called again llop.gc__collect(lltype.Void) llop.gc__collect(lltype.Void) return b.num_deleted * 10 + aid + 100 * (b.a is None)
def f(x): a = A() i = 0 while i < x: i += 1 a = A() llop.gc__collect(lltype.Void) llop.gc__collect(lltype.Void) aid = b.a.id b.a = None # check that __del__ is not called again llop.gc__collect(lltype.Void) llop.gc__collect(lltype.Void) return b.num_deleted * 10 + aid + 100 * (b.a is None)
def f(x): b.triggered = 0 g() i = 0 while i < x: i += 1 g() llop.gc__collect(lltype.Void) llop.gc__collect(lltype.Void) assert b.triggered > 0 g(); g() # two more llop.gc__collect(lltype.Void) llop.gc__collect(lltype.Void) num_deleted = 0 while fq.next_dead() is not None: num_deleted += 1 return num_deleted + 1000 * b.triggered
def f(x): b.triggered = 0 g() i = 0 while i < x: i += 1 g() llop.gc__collect(lltype.Void) llop.gc__collect(lltype.Void) assert b.triggered > 0 g() g() # two more llop.gc__collect(lltype.Void) llop.gc__collect(lltype.Void) num_deleted = 0 while fq.next_dead() is not None: num_deleted += 1 return num_deleted + 1000 * b.triggered
def run_once(): a = A() ida = compute_unique_id(a) b = B() idb = compute_unique_id(b) c = C() idc = compute_unique_id(c) llop.gc__collect(lltype.Void) llop.gc__collect(lltype.Void) llop.gc__collect(lltype.Void) return ida, idb, idc
def run_once(): a = A() ida = compute_unique_id(a) b = B() idb = compute_unique_id(b) c = C() idc = compute_unique_id(c) llop.gc__collect(lltype.Void) llop.gc__collect(lltype.Void) llop.gc__collect(lltype.Void) return ida, idb, idc
def f(): ref = g() llop.gc__collect(lltype.Void) llop.gc__collect(lltype.Void) result = a.count + (ref() is None) return result
def __del__(self): llop.gc__collect(lltype.Void) b.num_deleted += 1 C() C()
def f(x): ref = weakref.ref(a) assert ref() is a llop.gc__collect(lltype.Void) return ref() is a
def f(): a = A() a.x = 10 g(a) llop.gc__collect(lltype.Void) return a.x
def f(): ref = g() llop.gc__collect(lltype.Void) llop.gc__collect(lltype.Void) result = a.count + (ref() is None) return result
def g(): b = B() llop.gc__collect(lltype.Void) # force 'b' to be old ref = weakref.ref(B()) b.ref = ref return ref
def __del__(self): llop.gc__collect(lltype.Void) b.num_deleted += 1 C() C()
def f(): s1 = setup() llop.gc__collect(lltype.Void) return llmemory.cast_adr_to_ptr(getattr(s1, attrname), lltype.Ptr(T))
def f(x): ref = weakref.ref(a) assert ref() is a llop.gc__collect(lltype.Void) return ref() is a
def f(): t1 = lltype.malloc(T1) t1.x = 42 static.p = t1 llop.gc__collect(lltype.Void) return static.p.x
def f(): t1 = lltype.malloc(T1) t1.x = 42 static.p = t1 llop.gc__collect(lltype.Void) return static.p.x
def f(): a = A() a.x = 10 g(a) llop.gc__collect(lltype.Void) return a.x