This article covers features introduced in SpiderMonkey 1.8
Enable GC zeal, a testing and debugging feature that helps find GC-related bugs in JSAPI applications.
||A context. The GC zeal level of the associated
||The desired level of garbage collection:
||If this is
JS_SetGCZeal sets the level of garbage collection for a runtime. This is the
zeal argument. At level
0, the default, garbage collection rarely happens unless the application explicitly requests it. At level
1, SpiderMonkey collects at places that are likely to cause problems for embedders, such as when roots are removed. At level
2, SpiderMonkey collects every time an object, string, or function is allocated (or really every
frequency allocations). When the
compartment argument is
true, only the current compartment is collected. Otherwise, all compartments are collected.
compartment parameter was removed in Gecko 14.
Regularly running your test suite with GC zeal enabled at level 2 is a good practice.
This function is available only in
DEBUG builds. To enable this function in an optimized build, define the macro
JS_GC_ZEAL when building SpiderMonkey.
(In a debug build of Gecko, you can also set the current GC zeal level using the