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

  • Revision slug: Mozilla/Projects/SpiderMonkey/JSAPI_reference/JS_GC
  • Revision title: JS_GC
  • Revision id: 712489
  • Created:
  • Creator: arai
  • Is current revision? No
  • Comment fix format

Revision Content

{{SpiderMonkeySidebar("JSAPI")}}

Performs garbage collection in the JS memory pool.

Syntax

void JS_GC(JSRuntime *rt);
Name Type Description
rt {{jsapixref("JSRuntime", "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 {{jsapixref("JS_MaybeGC")}} instead.

Use {{jsapixref("JS_SetGCCallback")}} to add hooks that are called during garbage collection.

See Also

  • {{ LXRSearch("ident", "i", "JS_GC") }}
  • {{jsapixref("JS_MaybeGC")}}

Revision Source

<div>{{SpiderMonkeySidebar("JSAPI")}}</div>
<div class="summary">
<p>Performs garbage collection in the JS memory pool.</p>
</div>
<h2 id="Syntax" name="Syntax">Syntax</h2>
<pre class="brush: cpp">
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>{{jsapixref("JSRuntime", "JSRuntime *")}}</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 {{jsapixref("JS_MaybeGC")}} instead.</p>
<p>Use {{jsapixref("JS_SetGCCallback")}} to add hooks that are called during garbage collection.</p>
<h2 id="See_Also" name="See_Also">See Also</h2>
<ul>
<li>{{ LXRSearch("ident", "i", "JS_GC") }}</li>
<li>{{jsapixref("JS_MaybeGC")}}</li>
</ul>
Revert to this revision