v8 |手动启动垃圾收集器 [英] v8 | manually initiate the garbage collector

查看:127
本文介绍了v8 |手动启动垃圾收集器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法在Google的V8引擎上手动启动垃圾回收器?我找不到任何参考。通常情况下,GC支持这个功能。

解决方案

您可以公开 v8 :: HEAP-> CollectAllGarbage 函数通过命令标记 - expose_gc 添加到
全局JavaScript名称空间。然后
简单地调用 gc();


  • 通过声明:



    while(!V8 :: IdleNotification()){};




  • 参考文献:

    >

    Is there a way to manually initiate the garbage collector on Google's V8 engine? I couldn't find any reference for it. by usually GCs support this function.

    解决方案

    • You can expose the v8::HEAP->CollectAllGarbage function to the global JavaScript namespace via the command flag --expose_gc. Then simply call gc();.

    • You can force garbage collection from C++ via the statement:

      while(!V8::IdleNotification()) {};

    References:

    这篇关于v8 |手动启动垃圾收集器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆