diff options
Diffstat (limited to 'files/ja/mozilla/projects/spidermonkey/jsapi_reference/js_setgczeal/index.html')
-rw-r--r-- | files/ja/mozilla/projects/spidermonkey/jsapi_reference/js_setgczeal/index.html | 141 |
1 files changed, 141 insertions, 0 deletions
diff --git a/files/ja/mozilla/projects/spidermonkey/jsapi_reference/js_setgczeal/index.html b/files/ja/mozilla/projects/spidermonkey/jsapi_reference/js_setgczeal/index.html new file mode 100644 index 0000000000..0be58ee8dc --- /dev/null +++ b/files/ja/mozilla/projects/spidermonkey/jsapi_reference/js_setgczeal/index.html @@ -0,0 +1,141 @@ +--- +title: JS_SetGCZeal +slug: Mozilla/Projects/SpiderMonkey/JSAPI_reference/JS_SetGCZeal +tags: + - JSAPI Reference + - SpiderMonkey +translation_of: Mozilla/Projects/SpiderMonkey/JSAPI_reference/JS_SetGCZeal +--- +<div>{{SpiderMonkeySidebar("JSAPI")}}</div> + +<div>{{jsapi_minversion_header("1.8")}}</div> + +<div class="summary"> +<p>GC の活動量、JSAPI アプリケーションの GC 関連のバグを見つけるのに役立つテストおよびデバッグ機能を有効にします。</p> +</div> + +<h2 id="Syntax" name="Syntax">構文</h2> + +<pre class="brush: cpp">void +JS_SetGCZeal(JSContext *cx, uint8_t zeal, uint32_t frequency); +</pre> + +<table class="fullwidth-table"> + <tbody> + <tr> + <th>Name</th> + <th>Type</th> + <th>Description</th> + </tr> + <tr> + <td><code>cx</code></td> + <td>{{jsapixref("JSRuntime", "JSContext *")}}</td> + <td>A context. The GC zeal level of the associated {{jsapixref("JSRuntime")}} is set.</td> + </tr> + <tr> + <td><code>zeal</code></td> + <td><code>uint8_t</code></td> + <td>The desired level of garbage collection.</td> + </tr> + <tr> + <td><code>frequency</code></td> + <td><code>uint32_t</code></td> + <td>With some zeal levels, a GC is triggered every <code>frequency</code> allocations.</td> + </tr> + </tbody> +</table> + +<h2 id="Description" name="Description">説明</h2> + +<p><strong><code>JS_SetGCZeal</code></strong> sets the level of additional garbage collection to perform for a runtime, for the purpose of finding or reproducing bugs.</p> + +<p>There are several different levels which have different functions:</p> + +<table class="fullwidth-table"> + <thead> + <tr> + <th scope="col">Zeal level</th> + <th scope="col">Description</th> + </tr> + </thead> + <tbody> + <tr> + <td>0</td> + <td>Normal amount of collection. The default: no additional collections are performed.</td> + </tr> + <tr> + <td>1</td> + <td>Collect when roots are added or removed.</td> + </tr> + <tr> + <td>2</td> + <td>Collect when every <code>frequency</code> allocations.</td> + </tr> + <tr> + <td>3</td> + <td>Collect on window paints.</td> + </tr> + <tr> + <td>4</td> + <td>Verify pre write barriers between instructions.</td> + </tr> + <tr> + <td>5</td> + <td>Verify pre write barriers between window paints.</td> + </tr> + <tr> + <td>6</td> + <td>Verify stack rooting.</td> + </tr> + <tr> + <td>7</td> + <td>Collect the nursery every <code>frequency</code> nursery allocations.</td> + </tr> + <tr> + <td>8</td> + <td>Incremental GC in two slices: 1) mark roots 2) finish collection.</td> + </tr> + <tr> + <td>9</td> + <td>Incremental GC in two slices: 1) mark all 2) new marking and finish.</td> + </tr> + <tr> + <td>10</td> + <td>Incremental GC in multiple slices.</td> + </tr> + <tr> + <td>11</td> + <td>Verify post write barriers between instructions.</td> + </tr> + <tr> + <td>12</td> + <td>Verify post write barriers between paints.</td> + </tr> + <tr> + <td>13</td> + <td>Check internal hashtables on minor GC.</td> + </tr> + <tr> + <td>14</td> + <td>Perform a shrinking collection every <code>frequency</code> allocations.</td> + </tr> + </tbody> +</table> + +<p>With GC zeal enabled, GC-related crashes are much easier to reproduce (they happen more reliably) and debug (they happen sooner, closer to the source of the bug). The drawback is that GC zeal can cause JavaScript code to run extremely slowly.</p> + +<p>Regularly running your test suite with GC zeal enabled at level 2 is a good practice.</p> + +<p>This function is available only in <code>DEBUG</code> builds. To enable this function in an optimized build, define the macro <code>JS_GC_ZEAL</code> building SpiderMonkey.</p> + +<p>(In a debug build of Gecko, you can also set the current GC zeal level using the <code>javascript.options.gczeal</code> preference.)</p> + +<h2 id="See_Also" name="See_Also">あわせて参照</h2> + +<ul> + <li>{{LXRSearch("ident", "i", "JS_SetGCZeal")}}</li> + <li>{{LXRSearch("ident", "i", "JS_GC_ZEAL")}}</li> + <li>{{jsapixref("JS_ScheduleGC")}}</li> + <li>{{bug(308429)}}</li> + <li>{{bug(650978)}}</li> +</ul> |