释放资源是这样的:
如果有Close之类的方法,先执行o.Close()
然后 o=null;
但是,如果不关闭打开了该网页的浏览器,该ActiveX相应的dll文件将被一直占用,无法删除或修改这个没办法,IE的机制就是这样
如果有Close之类的方法,先执行o.Close()
然后 o=null;
但是,如果不关闭打开了该网页的浏览器,该ActiveX相应的dll文件将被一直占用,无法删除或修改这个没办法,IE的机制就是这样
will be destroyed when the object goes out of scope if it is never
explicitly set to nothing (VBScript) or null (JScript). The difference is what happens when you do set the object to nothing/null.
In VBScript, that immediately destroys the object. In JScript, the object
is destroyed when the garbage collector runs, which could be any time ( or forever if the free memory never drops).The JScript garbage collector works like this:
1) When the script engine is shut down, garbage is collected.
2) When 256 variants are allocated, or when more than 64K is allocated,
then the garbage collector sets a flag that says "collect soon".
3) Whenever a new statement is executed OR we break into the script
debugger, we check that flag, and if it is set, we do a collection. For TESTING purposes, there is a "collectGarbage" function which forces a
collection. I don't recommend shipping code that uses this function -- you
should design your programs to work well with automatic memory management.
If you have an algorithm which _depends_ on having a predictable collection
sequence, JScript is not an appropriate language for you to solve your
problem. Use a language with predictable GC behaviour, like VBScript.