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 696175 of JS_GC

  • Revision slug: Mozilla/Projects/SpiderMonkey/JSAPI_reference/JS_GC
  • Revision title: JS_GC
  • Revision id: 696175
  • Created:
  • Creator: JonCoppeard
  • Is current revision? No
  • Comment Corrected out-of-date function signature and updated description.

Revision Content

Performs garbage collection in the JS memory pool.

Syntax

void JS_GC(JSRuntime *rt);
Name Type Description
rt JSRuntime * The runtime to for which to perform garbage collection.

Description

JS_GC performs garbage collection of JS objects, strings and other internal data structures that are no longer reachable in the specified runtime. Garbage collection frees memory so that it can be reused by the system.

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.

Use JS_SetGCCallback to add hooks that are called during garbage collection.

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

Revision Source

<p>Performs garbage collection in the JS memory pool.</p>
<h2 id="Syntax" name="Syntax">Syntax</h2>
<pre class="eval">
void <strong>JS_GC</strong>(JSRuntime *rt);
</pre>
<table class="fullwidth-table">
 <tbody>
  <tr>
   <th>Name</th>
   <th>Type</th>
   <th>Description</th>
  </tr>
  <tr>
   <td><code>rt</code></td>
   <td><code><a href="/en/SpiderMonkey/JSAPI_Reference/JSRuntime" title="en/JSRuntime">JSRuntime</a> *</code></td>
   <td>The runtime to for which to perform garbage collection.</td>
  </tr>
 </tbody>
</table>
<h2 id="Description" name="Description">Description</h2>
<p><code>JS_GC</code> performs garbage collection of JS objects, strings and other internal data structures that are no longer reachable in the specified runtime. Garbage collection frees memory so that it can be reused by the system.</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/SpiderMonkey/JSAPI_Reference/JS_MaybeGC" title="en/JS_MaybeGC">JS_MaybeGC</a></code> instead.</p>
<p>Use <code><a href="/en/SpiderMonkey/JSAPI_Reference/JS_SetGCCallback" title="en/JS_SetGCCallback">JS_SetGCCallback</a></code> to add hooks that are called during garbage collection.</p>
<p>{{ LXRSearch("ident", "i", "JS_GC") }}</p>
Revert to this revision