JS::SetOutOfMemoryCallback 编辑

This article covers features introduced in SpiderMonkey 31

Specify a new callback function for Out of Memory error.

Syntax

void
JS::SetOutOfMemoryCallback(JSRuntime *rt, JS::OutOfMemoryCallback cb, void *data);
NameTypeDescription
rtJSRuntime *The JSRuntime for which to set the GC callback.
cbJS::OutOfMemoryCallbackPointer to the new callback function to use.
datavoid *data parameter which will be passed to JS::OutOfMemoryCallback. Added in SpiderMonkey 38

Callback syntax

typedef void
(* OutOfMemoryCallback)(JSContext *cx, void *data);
NameTypeDescription
datavoid *data parameter passed to JS::SetOutOfMemoryCallback. Added in SpiderMonkey 38

Description

Unlike the error reporter, which is only called if the exception for an OOM bubbles up and is not caught, the JS::OutOfMemoryCallback is called immediately at the OOM site to allow the embedding to capture the current state of heap allocation before anything is freed. If the large-allocation-failure callback is called at all (not all allocation sites call the large-allocation-failure callback on failure), it is called before the out-of-memory callback; the out-of-memory callback is only called if the allocation still fails after the large-allocation-failure callback has returned.

JS::SetOutOfMemoryCallback sets a callback function for it.

See Also

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:54 次

字数:3178

最后编辑:7年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文