什么是Javascript方法CollectGarbage()?什么时候以及为什么要使用它? [英] What is the Javascript method CollectGarbage()? When and why should it be used?

查看:82
本文介绍了什么是Javascript方法CollectGarbage()?什么时候以及为什么要使用它?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我注意到在VS2010 javascript智能中,有一种称为CollectGarbage()的方法.

I notice in the VS2010 javascript intellisence there is a method called CollectGarbage().

这是仅IE的方法吗?
什么时候应该使用?
使用它有什么优点(或缺点)?

Is this an IE only method?
When should it be used?
What are the advantages (or disadvantages) to using it?

推荐答案

您可能想看看

这是仅限IE的方法吗?

Is this an IE only method?

不.它是JScript的一部分,因此任何实现 JScript (当然包括IE)的人都应该支持它.

Nope. It's part of JScript, so anything that implements JScript (including IE, of course) should support it.

何时应使用它?

When should it be used?

当您要提示垃圾收集器开始执行其工作时.可以说,它根本不应该使用,而应该让事情自己发生.

When you want to hint garbage collector to start doing its job. Arguably, it shouldn't be used at all, and instead just let things happen on their own.

使用它有什么优点(或缺点)?

What are the advantages (or disadvantages) to using it?

我没有发现任何不利之处.在使用它之前,我将进行一些测试,以查看内存使用是否有实际好处.

I'm not aware of any disadvantages. Before using it, I would perform some tests to see if there are actual benefits in memory usage.

这篇关于什么是Javascript方法CollectGarbage()?什么时候以及为什么要使用它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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