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);
Name | Type | Description |
---|---|---|
rt | JSRuntime * | The JSRuntime for which to set the GC callback. |
cb | JS::OutOfMemoryCallback | Pointer to the new callback function to use. |
data | void * | data parameter which will be passed to JS::OutOfMemoryCallback . Added in SpiderMonkey 38 |
Callback syntax
typedef void
(* OutOfMemoryCallback)(JSContext *cx, void *data);
Name | Type | Description |
---|---|---|
data | void * | 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论