Destroy a JSContext.


JS_DestroyContext(JSContext *cx);

JS_DestroyContextNoGC(JSContext *cx);

JS_DestroyContextMaybeGC(JSContext *cx); // Obsolete since JSAPI 14
Name Type Description
cx JSContext * The context to destroy.


These functions destroy a context, cx. JS_DestroyContext additionally performs garbage collection to reclaim any memory that was being used by cx's global object. JS_DestroyContextNoGC does not perform garbage collection. JS_DestroyContextMaybeGC may or may not perform garbage collection; the engine makes an educated guess as to whether enough memory would be reclaimed to justify the work.

In a JS_THREADSAFE build, it does not matter whether the calling thread is in a request on cx. However, there must not be any suspended requests on cx.

If JS_SetContextCallback has been called, this calls the callback.

See Also