Author: Armin Rigo <[email protected]>
Branch: gc-del-2
Changeset: r66072:a71ae5ca9f55
Date: 2013-08-11 17:44 +0200
http://bitbucket.org/pypy/pypy/changeset/a71ae5ca9f55/
Log: Second test: a full collection that discovers a chain of old
unreachable objects should make them all young again, so that it
goes away at the rythm of one per minor collect from that point.
diff --git a/rpython/memory/test/test_minimark_gc.py
b/rpython/memory/test/test_minimark_gc.py
--- a/rpython/memory/test/test_minimark_gc.py
+++ b/rpython/memory/test/test_minimark_gc.py
@@ -1,5 +1,6 @@
from rpython.rlib import rgc
from rpython.rlib.debug import ll_assert
+from rpython.rlib.objectmodel import keepalive_until_here
from rpython.rlib.rarithmetic import LONG_BIT
from rpython.memory.test import test_semispace_gc
@@ -45,3 +46,41 @@
i += 1
self.interpret(f, [4])
+
+ def test_finalizer_chain_minor_collect_old(self):
+ class A:
+ def __init__(self, n, next):
+ self.n = n
+ self.next = next
+ def __del__(self):
+ state.freed.append(self.n)
+ class State:
+ pass
+ state = State()
+
+ def make(n):
+ a = None
+ i = 0
+ while i < n:
+ a = A(i, a)
+ i += 1
+ rgc.collect() # make all objects old
+ keepalive_until_here(a)
+
+ def f(n):
+ state.freed = []
+ make(n)
+ ll_assert(len(state.freed) == 0, "should be empty before collect")
+ rgc.collect() # need a full collection to initiate deletion
+ ll_assert(len(state.freed) == 1, "should be 1 after first collect")
+ i = 1
+ while i < n:
+ rgc.collect(0) # minor collection only
+ i += 1
+ ll_assert(len(state.freed) == i, "every collect should grow 1")
+ i = 0
+ while i < n:
+ ll_assert(state.freed[i] == n - i - 1, "bogus ordering")
+ i += 1
+
+ self.interpret(f, [4])
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit