Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Revision 147053 of JS_GC

  • Revision slug: SpiderMonkey/JSAPI_Reference/JS_GC
  • Revision title: JS_GC
  • Revision id: 147053
  • Created:
  • Creator: Jorend
  • Is current revision? No
  • Comment style, wording

Revision Content

{{template.Jsapi_ref_header("JS_GC")}}

Performs garbage collection in the JS memory pool.

Syntax

void JS_GC(JSContext *cx);
Name Type Description
cx JSContext * The context to use. JS_GC collects unreachable objects from the associated JSRuntime, regardless of which JSContext created them. This context is passed to JSClass.finalize hooks.

Description

JS_GC performs garbage collection, if necessary, of JS objects, doubles, and strings that are no longer needed by a script executing in a specified JSContext, cx. Garbage collection frees space in the memory pool so that it can be reused by the JS engine.

When your scripts create many objects, you may want to call JS_GC directly in your code, particularly when a script terminates or when the application has idle time. To perform garbage collection only if needed, call JS_MaybeGC instead of JS_GC.

{{template.LXRSearch("ident", "i", "JS_GC")}}

Revision Source

<p>{{template.Jsapi_ref_header("JS_GC")}}
</p><p>Performs garbage collection in the JS memory pool.
</p>
<h2 name="Syntax"> Syntax </h2>
<pre class="eval">void <b>JS_GC</b>(<a href="en/JSContext">JSContext</a> *cx);
</pre>
<table class="fullwidth-table">
<tbody><tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
</tr>
<tr>
<td><code>cx</code></td>
<td><code><a href="en/JSContext">JSContext</a> *</code></td>
<td>The context to use.  <code>JS_GC</code> collects unreachable objects from the associated <code><a href="en/JSRuntime">JSRuntime</a></code>, regardless of which <code>JSContext</code> created them.  This context is passed to <code><a href="en/JSClass.finalize">JSClass.finalize</a></code> hooks.</td>
</tr>
</tbody></table>
<h2 name="Description"> Description </h2>
<p><code>JS_GC</code> performs garbage collection, if necessary, of JS objects, doubles, and strings that are no longer needed by a script executing in a specified <code>JSContext</code>, <code>cx</code>. Garbage collection frees space in the memory pool so that it can be reused by the JS engine.
</p><p>When your scripts create many objects, you may want to call <code>JS_GC</code> directly in your code, particularly when a script terminates or when the application has idle time.  To perform garbage collection only if needed, call <code><a href="en/JS_MaybeGC">JS_MaybeGC</a></code> instead of <code>JS_GC</code>.
</p><p>{{template.LXRSearch("ident", "i", "JS_GC")}}
</p>
Revert to this revision