JScript Uses a mark-and-sweep Garbage Collector with a variety of heuristics use to determine. 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 Collectes 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? .NET will use the .NET 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 Life Time, JScript is not the right tool for the job. Trying to make it it is getministic-lifetime language will just create Headaches Down the Road.
JS's memory management is similar to Java's memory management! You can see Java's memory management mechanism.
The memory that releases an object must first release all references to the object. But when the object is not applied by any variable, Browse does not necessarily release the memory occupied by the object.
Collectgarbage () is not recommended.
When IE minimizes, garbage collection is carried out!