JS_NewRuntime 编辑
Initializes the JavaScript runtime.
Syntax
JSRuntime *
JS_NewRuntime(uint32_t maxbytes,
uint32_t maxNurseryBytes = JS::DefaultNurseryBytes,
JSRuntime *parentRuntime = nullptr);
JSRuntime *
JS_NewRuntime(uint32_t maxbytes, JSUseHelperThreads useHelperThreads,
JSRuntime *parentRuntime = nullptr); // Deprecated since JSAPI 32
Name | Type | Description |
---|---|---|
maxbytes | uint32 | Maximum number of allocated bytes after which garbage collection is run. |
maxNurseryBytes | uint32 | Nursery size in bytes. maxNurseryBytes is rounded down to a multiple of chunk size. Added in SpiderMonkey 38 |
parentRuntime | JSRuntime * | The topmost parent or nullptr . Added in SpiderMonkey 31 |
Description
JS_NewRuntime
initializes the JavaScript runtime environment. Call JS_NewRuntime
before making any other API calls except JS_Init
. JS_NewRuntime
allocates memory for the JSRuntime
and initializes certain internal runtime structures. maxbytes
specifies the number of allocated bytes after which garbage collection is run. If parentRuntime
is specified, the resulting runtime shares significant amounts of read-only state (the self-hosting and initial atoms compartments). It is recommended to make use of this for every runtime in a process after the first one.
The returned JSRuntime
can be used from the calling thread only. (The engine may use helper threads internally, though.)
On success, JS_NewRuntime
returns a pointer to the newly created runtime, which the caller must later destroy using JS_DestroyRuntime
. Otherwise it returns NULL
.
Notes
Ordinarily, JS_NewRuntime
should be the first JSAPI call in an application, and JS_DestroyRuntime
and JS_ShutDown
should be the last ones.
See Also
- MXR ID Search for
JS_NewRuntime
JS_Init
JS_DestroyRuntime
JS_ShutDown
- bug 714050 - added useHelperThreads parameter
- bug 964059 - added parentRuntime parameter
- bug 941805 - removed useHelperThreads parameter
- bug 1034621 - added maxNurseryBytes parameter
- bug 1286795 - JS_NewRuntime is renamed to JS_NewContext
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论