邮件订阅
5ucms模版,JS中关于对内存的释放问题[待续]
作者: 来源: 日期:2015/11/8 22:08:31 浏览量:44(滞后) 人气:LOADING...(实时) 【

5ucms模版,JS中关于对内存的释放问题[待续]

JScript uses a mark-and-sweep garbage collector with a variety of heuristics used to determine when to run garbage collection. The JScript garbage collector works like this:

1、When the script engine is shut down, garbage is collected.

2、When 256 variants, or more than 64KB of strings, or more than 4096 array slots have been allocated, the garbage collector sets a flag that says collect soon.

3、Whenever a new statement is executed or the script debugger starts, that flag is checked, and if it is set, a collection is done.

There is an undocumented JScript function called CollectGarbage that forces a garbage collection. This is for testing purposes only—do not ship code that calls this function. It is a poor programming practice to write code in JScript that depends on garbage collections being done at particular times. If you need predictable garbage collection, use a language that supports it (like Visual Basic? or VBScript). Note that all of this is the implementation detail of the engine and should not be relied upon because it may change in the future. Note also that the version of JScript supported by Microsoft? will use the Framework garbage collector, a multigenerational mark-and-sweep collector.
And remember, if you want a deterministic-lifetime app, use a deterministic-lifetime language like C++, Visual Basic 6.0, or VBScript; not an indeterministic-lifetime language like JScript, Scheme, or Java. If you''re writing a program that depends on being able to have a deterministic object lifetime, JScript is not the right tool for the job. Trying to make it a deterministic-lifetime language will just create headaches down the road.

js的内存管理类似于java的内存管理!你可以参看java的内存管理机制。

释放一个对象所占的内存必须先释放所有对该对象的引用。

但当对象没有被任何变量应用时,browse也不一定释放该对象所占的内存。

CollectGarbage()并不是推荐的方法。

ie最小化时,会进行垃圾回收!


欢迎您访问www.5ucms.org

本站推荐: 5ucms模板下载 5ucms插件下载 仿站联系Q3876307       [复制给好友] [打印] [关闭] [返回] [顶部]
上一篇:5ucms插件,用JScript实现公历到农历的日期转换
下一篇:5ucms仿站,关于IP验证的一个例子
本站声明:本网站所载文章等内容,目的在于传递更多信息,并不代表本网赞同其观点和对其真实性负责。如涉及作品内容、版权及其它问题,请在30日内与本网联系(Email:3876307#qq.com),我们将在第一时间删除内容。若原创内容转载请注明出处。
5ucms模版,JS中关于对内存的释放问题[待续]的关键词:
评论信息
相关分类
本周热门
本月热门
关于我们 - 版权/免责 申明 - 建站服务 - 网站地图 - 稿件投递 - 联系我们 - 5ucms
Copyright © 2008-2015 www.5ucms.org