Reports a memory allocation error.

Syntax

void
JS_ReportOutOfMemory(JSContext *cx);

void
JS_ReportAllocationOverflow(JSContext *cx); // Added in SpiderMonkey 1.8
Name Type Description
cx JSContext * The context in which to report the error.

Description

Call JS_ReportOutOfMemory to report that an operation failed because the system is out of memory. When the JavaScript engine tries to allocate memory and allocation fails, it reports an error as though by calling this function.

Call JS_ReportAllocationOverflow if an operation fails because it tries to use more memory (or more of some other resource) than the application is designed to handle. When a script tries to grow an array beyond 230-1 elements, for example, or concatenate strings such that the result is more than 229-1 characters long, the JavaScript engine reports an error as though by calling this function.

See JS_ReportError and JS_SetErrorReporter for more information about error handling in the JSAPI.

See Also