• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python llop.gc__collect函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pypy.rpython.lltypesystem.lloperation.llop.gc__collect函数的典型用法代码示例。如果您正苦于以下问题:Python gc__collect函数的具体用法?Python gc__collect怎么用?Python gc__collect使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了gc__collect函数的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: f

 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
开发者ID:pombredanne,项目名称:pypy,代码行数:7,代码来源:test_newgc.py


示例2: f

 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
开发者ID:alkorzt,项目名称:pypy,代码行数:30,代码来源:test_transformed_gc.py


示例3: concat

 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
开发者ID:alkorzt,项目名称:pypy,代码行数:8,代码来源:test_transformed_gc.py


示例4: concat

 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
开发者ID:enyst,项目名称:plexnet,代码行数:9,代码来源:test_gc.py


示例5: h

 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
开发者ID:TheDunn,项目名称:flex-pypy,代码行数:11,代码来源:test_newgc.py


示例6: f

 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
开发者ID:antoine1fr,项目名称:pygirl,代码行数:11,代码来源:test_genllvm.py


示例7: func

 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
开发者ID:alkorzt,项目名称:pypy,代码行数:12,代码来源:test_transformed_gc.py


示例8: malloc_a_lot

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)
开发者ID:antoine1fr,项目名称:pygirl,代码行数:12,代码来源:test_stackless.py


示例9: f

 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
开发者ID:TheDunn,项目名称:flex-pypy,代码行数:13,代码来源:test_transformed_gc.py


示例10: f

 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)
开发者ID:enyst,项目名称:plexnet,代码行数:13,代码来源:test_gc.py


示例11: f

 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
开发者ID:antoine1fr,项目名称:pygirl,代码行数:20,代码来源:test_ll_thread.py


示例12: f

        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"
开发者ID:enyst,项目名称:plexnet,代码行数:41,代码来源:snippet.py


示例13: run_once

 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
开发者ID:antoine1fr,项目名称:pygirl,代码行数:11,代码来源:test_boehm.py


示例14: f

 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
开发者ID:TheDunn,项目名称:flex-pypy,代码行数:11,代码来源:test_boehm.py


示例15: g

 def g(a):
     llop.gc__collect(lltype.Void)
     for i in range(1000):
         prepare(B(), -1)    # probably overwrites collected memory
     return a.value
开发者ID:pombredanne,项目名称:pypy,代码行数:5,代码来源:test_newgc.py


示例16: __del__

 def __del__(self):
     llop.gc__collect(lltype.Void)
     b.num_deleted += 1
     C()
     C()
开发者ID:alkorzt,项目名称:pypy,代码行数:5,代码来源:test_transformed_gc.py


示例17: append_to_list

 def append_to_list(i, j):
     box.lst.append([i] * 50)
     llop.gc__collect(lltype.Void)
     return box.lst[j][0]
开发者ID:alkorzt,项目名称:pypy,代码行数:4,代码来源:test_transformed_gc.py



注:本文中的pypy.rpython.lltypesystem.lloperation.llop.gc__collect函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python lltype.cast_opaque_ptr函数代码示例发布时间:2022-05-27
下一篇:
Python llop.debug_print函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap