예제 #1
0
 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
예제 #2
0
 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
예제 #3
0
 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
예제 #4
0
 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
예제 #5
0
 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
예제 #6
0
 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
예제 #7
0
 def f(x, y):
     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
예제 #8
0
파일: test_gc.py 프로젝트: enyst/plexnet
 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
예제 #9
0
 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
예제 #10
0
 def h():
     f = Weakrefable()
     f.x = 32
     ref1 = get_weakref(f, g1)
     ref2 = get_weakref(f, g2)
     if f.x % 2 == 0: # start a new block to make sure ref2 dies before f
         ref2 = None
     f.x = 12
     llop.gc__collect(lltype.Void)
     llop.gc__collect(lltype.Void)
     return ref1
예제 #11
0
 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
예제 #12
0
 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
예제 #13
0
def malloc_a_lot():
    i = 0
    while i < 10:
        i += 1
        a = [1] * 10
        j = 0
        while j < 20:
            j += 1
            a.append(j)
    from pypy.rpython.lltypesystem.lloperation import llop
    from pypy.rpython.lltypesystem import lltype
    llop.gc__collect(lltype.Void)
예제 #14
0
 def func():
     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
예제 #15
0
def malloc_a_lot():
    i = 0
    while i < 10:
        i += 1
        a = [1] * 10
        j = 0
        while j < 20:
            j += 1
            a.append(j)
    from pypy.rpython.lltypesystem.lloperation import llop
    from pypy.rpython.lltypesystem import lltype
    llop.gc__collect(lltype.Void)
예제 #16
0
파일: test_gc.py 프로젝트: enyst/plexnet
 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)
예제 #17
0
 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
     return b.num_deleted
예제 #18
0
 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
예제 #19
0
 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)
예제 #20
0
 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
     return b.num_deleted
예제 #21
0
 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)
예제 #22
0
 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
예제 #23
0
 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
예제 #24
0
파일: test_gc.py 프로젝트: enyst/plexnet
 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
예제 #25
0
 def f():
     main_ident = get_ident()
     assert main_ident == get_ident()
     state.freed_counter = 0
     for i in range(50):
         state.done = 0
         state.seen_value = 0
         g(i)
         willing_to_wait_more = 1000
         while not state.done:
             willing_to_wait_more -= 1
             if not willing_to_wait_more:
                 raise Exception("thread didn't start?")
             time.sleep(0.01)
         assert state.my_thread_ident != main_ident
         assert state.seen_value == i
     # try to force Boehm to do some freeing
     for i in range(3):
         llop.gc__collect(lltype.Void)
     return state.freed_counter
예제 #26
0
 def f():
     main_ident = get_ident()
     assert main_ident == get_ident()
     state.freed_counter = 0
     for i in range(50):
         state.done = 0
         state.seen_value = 0
         g(i)
         willing_to_wait_more = 1000
         while not state.done:
             willing_to_wait_more -= 1
             if not willing_to_wait_more:
                 raise Exception("thread didn't start?")
             time.sleep(0.01)
         assert state.my_thread_ident != main_ident
         assert state.seen_value == i
     # try to force Boehm to do some freeing
     for i in range(3):
         llop.gc__collect(lltype.Void)
     return state.freed_counter
예제 #27
0
        def f(_):
            i = 0
            while i < len(examples):
                input, components, strict = examples[i]
                build_example(input)
                while state.time < len(letters):
                    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, state.age[c]))
                summary = ', '.join(lst)

                # check that all instances have been finalized
                if -1 in state.age.values():
                    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 state.age[c] >= state.age[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 = state.age[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"
예제 #28
0
 def f(x, y):
     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)
예제 #29
0
 def f(i):
     if i:
         s.a_dels = 0
         a = A()
         # this should not keep a alive
         s.a = cast_object_to_weakgcaddress(a)
         a = None
     llop.gc__collect(lltype.Void)
     llop.gc__collect(lltype.Void)
     llop.gc__collect(lltype.Void)
     return s.a_dels
예제 #30
0
 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
예제 #31
0
파일: test_boehm.py 프로젝트: njues/Sypy
 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
예제 #32
0
 def f():
     t1 = lltype.malloc(T1)
     t1.x = 42
     static.p = t1
     llop.gc__collect(lltype.Void)
     return static.p.x
예제 #33
0
 def f():
     make()
     llop.gc__collect(lltype.Void)
     return global_a.b.a.b.c
예제 #34
0
 def g(a):
     llop.gc__collect(lltype.Void)
     for i in range(1000):
         prepare(B(), -1)    # probably overwrites collected memory
     return a.value
예제 #35
0
 def __del__(self):
     llop.gc__collect(lltype.Void)
     b.num_deleted += 1
     C()
     C()
예제 #36
0
 def f():
     ref = g()
     llop.gc__collect(lltype.Void)
     llop.gc__collect(lltype.Void)
     result = a.count == 1 and (ref() is None)
     return result
예제 #37
0
 def f():
     make()
     llop.gc__collect(lltype.Void)
     return a.x.y
예제 #38
0
 def f(i):
     a = A()
     f1(i)
     a.b = 1
     llop.gc__collect(lltype.Void)
     return a.b
예제 #39
0
 def f():
     make()
     llop.gc__collect(lltype.Void)
     return a.x.y
예제 #40
0
 def append_to_list(i, j):
     box.lst.append([i] * 50)
     llop.gc__collect(lltype.Void)
     return box.lst[j][0]
예제 #41
0
 def f(n):
     s1 = setup()
     llop.gc__collect(lltype.Void)
     return measure_length(s1)
예제 #42
0
 def f():
     p = lltype.malloc(B)
     llop.gc__collect(lltype.Void)
     p.a = lltype.malloc(A)
     return p.a.x
예제 #43
0
 def g(a):
     llop.gc__collect(lltype.Void)
     for i in range(1000):
         prepare(B(), -1)    # probably overwrites collected memory
     return a.value
예제 #44
0
 def f(i):
     a = A()
     f1(i)
     a.b = 1
     llop.gc__collect(lltype.Void)
     return a.b
예제 #45
0
 def f():
     p = lltype.malloc(B)
     llop.gc__collect(lltype.Void)
     p.a = lltype.malloc(A)
     return p.a.x