有没有办法在基于webkit的浏览器中强制使用Javascript垃圾收集器? [英] Is there any way to force the Javascript Garbage Collector in webkit based browsers?

查看:268
本文介绍了有没有办法在基于webkit的浏览器中强制使用Javascript垃圾收集器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Internet Explorer中,我们可以使用此方法强制执行Javascript垃圾收集:CollectGarbage();

In internet explorer we can force the Javascript garbage collection to execute with this method: CollectGarbage();

Firefox上未定义该方法。你知道是否有某种等价物吗?

That method is undefined on Firefox. Do you know if there is some kind of equivalent?

谢谢。

推荐答案

(不只是将此答案限制在基于WebKit的浏览器......)

(Not just limiting this answer to WebKit-based browsers...)


  • Chrome:如果从命令行启动它/ terminal with - js-flags = - expose-gc,然后它提供 window.gc()

  • Firefox我认为需要点击中的可用内存按钮:内存

  • Opera有 window.opera.collect()

  • Edge有 window.CollectGarbage()

  • Safari,未知。

  • Chrome: if you launch it from a command line/terminal with --js-flags="--expose-gc", then it provides window.gc().
  • Firefox I think requires clicking the "Free memory" buttons in about:memory.
  • Opera has window.opera.collect().
  • Edge has window.CollectGarbage().
  • Safari, unknown.

请注意,你不应该不要手动运行GC。我只发布了这个,因为它对开发测试很有用。

Note that you shouldn't be manually running the GC. I've only posted this because it's useful for development testing.

这篇关于有没有办法在基于webkit的浏览器中强制使用Javascript垃圾收集器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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