JS_ShutDown

  • Revision slug: SpiderMonkey/JSAPI_Reference/JS_ShutDown
  • Revision title: JS_ShutDown
  • Revision id: 448731
  • Created:
  • Creator: Waldo
  • Is current revision? Yes
  • Comment Update documentation to reflec the changes made in bug 896124

Revision Content

Free all resources used by the JS engine, not associated with specific runtimes.

Syntax

void JS_ShutDown(void);

Description

Destroys all free-standing resources allocated by SpiderMonkey, not associated with any JSRuntime, JSContext, or other structure.

This method should be called after all other JSAPI data has been properly cleaned up: every JSRuntime created with JS_NewRuntime must have been destroyed with JS_DestroyRuntime, every JSContext created with JS_NewContext must have been destroyed with JS_DestroyContext, and so on.  Calling this method before all other resources have been destroyed has undefined behavior.

Failure to call this method, at present, has no adverse effects other than leaking memory.  This may not always be the case; it's recommended that all embedders call this method when all other JSAPI operations have completed, to be future-proof.

It is currently not possible to initialize SpiderMonkey multiple times (that is, calling JS_Init, then other JSAPI methods, then JS_ShutDown in that order, then doing so again).  This restriction may eventually be lifted.

Implementation note: This method has been used to clean up memory allocated by jsdtoa.cpp, memory allocated to implement Date.now() on Windows, and when the Internationalization API is enabled, memory internally allocated by ICU.  Exact details about what this method cleans up will vary depending upon the version of SpiderMonkey in use.

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

{{ languages( { "ja": "ja/JS_ShutDown" } ) }}

Revision Source

<p>Free all resources used by the JS engine, not associated with specific runtimes.</p>
<h2 id="Syntax" name="Syntax">Syntax</h2>
<pre class="eval">
void <strong>JS_ShutDown</strong>(void);
</pre>
<h2 id="Description" name="Description">Description</h2>
<p>Destroys all free-standing resources allocated by SpiderMonkey, not associated with any <a href="/en-US/docs/SpiderMonkey/JSAPI_Reference/JSRuntime" title="/en-US/docs/SpiderMonkey/JSAPI_Reference/JSRuntime"><code>JSRuntime</code></a>, <code>JSContext</code>, or other structure.</p>
<p>This method should be called after all other JSAPI data has been properly cleaned up: every <a href="/en-US/docs/SpiderMonkey/JSAPI_Reference/JSRuntime" title="/en-US/docs/SpiderMonkey/JSAPI_Reference/JSRuntime"><code>JSRuntime</code></a> created with <a href="/en-US/docs/SpiderMonkey/JSAPI_Reference/JS_NewRuntime" title="/en-US/docs/SpiderMonkey/JSAPI_Reference/JS_NewRuntime"><code>JS_NewRuntime</code></a> must have been destroyed with <a href="/en-US/docs/SpiderMonkey/JSAPI_Reference/JS_DestroyRuntime" title="/en-US/docs/SpiderMonkey/JSAPI_Reference/JS_DestroyRuntime"><code>JS_DestroyRuntime</code></a>, every <code>JSContext</code> created with <a href="/en-US/docs/SpiderMonkey/JSAPI_Reference/JS_NewContext" title="/en-US/docs/SpiderMonkey/JSAPI_Reference/JS_NewContext"><code>JS_NewContext</code></a> must have been destroyed with <a href="/en-US/docs/SpiderMonkey/JSAPI_Reference/JS_DestroyContext" title="/en-US/docs/SpiderMonkey/JSAPI_Reference/JS_DestroyContext"><code>JS_DestroyContext</code></a>, and so on.&nbsp; Calling this method before all other resources have been destroyed has undefined behavior.</p>
<p>Failure to call this method, at present, has no adverse effects other than leaking memory.&nbsp; This may not always be the case; it's recommended that all embedders call this method when all other JSAPI operations have completed, to be future-proof.</p>
<p>It is currently not possible to initialize SpiderMonkey multiple times (that is, calling JS_Init, then other JSAPI methods, then JS_ShutDown in that order, then doing so again).&nbsp; This restriction may eventually be lifted.</p>
<p>Implementation note: This method has been used to clean up memory allocated by <code>jsdtoa.cpp</code>, memory allocated to implement <code><a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/now" title="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/now">Date.now()</a></code> on Windows, and when the Internationalization API is enabled, memory internally allocated by ICU.&nbsp; Exact details about what this method cleans up will vary depending upon the version of SpiderMonkey in use.</p>
<p>{{ LXRSearch("ident", "i", "JS_ShutDown") }}</p>
<p>{{ languages( { "ja": "ja/JS_ShutDown" } ) }}</p>
Revert to this revision