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 dump_heap_stats(space, filename): tb = rgc._heap_stats() if not tb: raise oefmt(space.w_RuntimeError, "Wrong GC") f = open(filename, mode="w") for i in range(len(tb)): f.write("%d %d " % (tb[i].count, tb[i].size)) f.write(",".join([str(tb[i].links[j]) for j in range(len(tb))]) + "\n") f.close()
def f(): for i in range(10): s = lltype.malloc(S) l1.append(s) l2.append(s) l3.append(s) tb = rgc._heap_stats() a = 0 nr = 0 b = 0 c = 0 for i in range(len(tb)): if tb[i].count == 10: # the type of S a += 1 nr = i for i in range(len(tb)): if tb[i].count == 3: # the type GcArray(Ptr(S)) b += 1 c += tb[i].links[nr] # b can be 1 or 2 here since _heap_stats() is free to return or # ignore the three GcStructs that point to the GcArray(Ptr(S)). # important one is c, a is for check return c * 100 + b * 10 + a
def fn(): return bool(rgc._heap_stats())