什么是Javascript方法CollectGarbage()?什么时候以及为什么要使用它?

编程入门 行业动态 更新时间:2024-10-27 22:22:26
本文介绍了什么是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?

推荐答案

您可能想看看这篇文章,作者:埃里克·利珀特(Eric Lippert).

这是仅限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()?什么时候以及为什么要使用它?

本文发布于:2023-11-12 09:27:15,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1581110.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:什么时候   用它   要使   方法   Javascript

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!