Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

JS NewRuntime

このテンプレートは廃止されています。使用しないで下さい。

JavaScript ランタイムの初期化を行います。

構文

JSRuntime * JS_NewRuntime(uint32 maxbytes);
Name Type Description
maxbytes uint32 ガベージコレクション動作後の最大メモリ使用量Maximum number of allocated bytes after which garbage collection is run.

説明

JS_NewRuntimeは、JavaScriptランタイム環境の初期化を行う関数です。他のJSAPI関数を使うには前もって必ずJS_NewRuntimeを呼ぶことになります。JS_NewRuntimeは、JSRuntimeに用いるメモリ領域を確保し、ランタイム内の初期化を行います。引数maxbytesで、ガベージコレクションが動作した後の最大メモリ使用量を指定します。 <code>JS_NewRuntime</code> initializes the JavaScript runtime environment. Call <code>JS_NewRuntime</code> before making any other API calls. <code>JS_NewRuntime</code> allocates memory for the <code>JSRuntime</code> and initializes certain internal runtime structures. <code>maxbytes</code> specifies the number of allocated bytes after which garbage collection is run.

一般的に、ほとんどのアプリケーションで必要とされるJSRuntimeは一つのみです。JS_THREADSAFEを有効にしたビルドでは、JSRuntimeを共有するJSContextを各スレッドごとに一つ用意することで、複数スレッドからランタイムにアクセスすることが可能です。複数のランタイムが必要になるのは、JavaScriptの値やオブジェクト、関数をスレッド間で完全に分離させたいときだけです。 Generally speaking, most applications need only one <code>JSRuntime</code>. In a <code>JS_THREADSAFE</code> build, each runtime is capable of handling multiple execution threads, using one <code>JSContext</code> per thread, sharing the same <code>JSRuntime</code>. You only need multiple runtimes if your application requires completely separate JS engines that cannot share values, objects, and functions.

JS_NewRuntimeが成功したときは、新たに生成されたランタイムへのポインタがその返り値となり、失敗した時はNULLを返します。JS_NewRuntimeの呼び出し元は、後で必ずそのランタイムをJS_DestroyRuntimeを用いて破棄しなければなりません。 On success, <code>JS_NewRuntime</code> returns a pointer to the newly created runtime, which the caller must later destroy using <code>JS_DestroyRuntime</code>. Otherwise it returns <code>NULL</code>.

注記

一般的には、JS_NewRuntimeはアプリケーション内でまず最初に実行し、JS_DestroyRuntimeJS_ShutDownを終了時に呼ぶことになります。 Ordinarily, <code>JS_NewRuntime</code> should be the first JSAPI call in an application, and <code>JS_DestroyRuntime</code> and <code>JS_ShutDown</code> should be the last ones.

MXR ID で JS_NewRuntime

ドキュメントのタグと貢献者

 このページの貢献者: fscholz, Marsf, Norihiro
 最終更新者: fscholz,