aboutsummaryrefslogtreecommitdiff
path: root/files/ja/mozilla/projects/spidermonkey/jsapi_reference/js_getgcparameter/index.html
blob: 1bfa969e7c2739b705108bbbbe5be52f4fe09644 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
---
title: JS_GetGCParameter
slug: Mozilla/Projects/SpiderMonkey/JSAPI_reference/JS_GetGCParameter
tags:
  - JSAPI Reference
  - SpiderMonkey
translation_of: Mozilla/Projects/SpiderMonkey/JSAPI_reference/JS_GetGCParameter
---
<div>{{SpiderMonkeySidebar("JSAPI")}}</div>

<div class="summary">
<p>ガベージコレクションに関連するパフォーマンスパラメータを調整します。</p>
</div>

<h2 id="Syntax" name="Syntax">構文</h2>

<pre class="brush: cpp">uint32_t
JS_GetGCParameter(JSRuntime *rt, JSGCParamKey key);

void
JS_SetGCParameter(JSRuntime *rt, JSGCParamKey key, uint32_t value);

uint32_t
JS_GetGCParameterForThread(JSContext *cx, JSGCParamKey key); // Added in SpiderMonkeySidebar 17

void
JS_SetGCParameterForThread(JSContext *cx, JSGCParamKey key, uint32_t value); // Added in SpiderMonkeySidebar 17
</pre>

<table class="fullwidth-table">
 <tbody>
  <tr>
   <th>Name</th>
   <th>Type</th>
   <th>Description</th>
  </tr>
  <tr>
   <td><code>rt</code></td>
   <td>{{jsapixref("JSRuntime", "JSRuntime *")}}</td>
   <td>The runtime to configure.</td>
  </tr>
  <tr>
   <td><code>cx</code></td>
   <td>{{jsapixref("JSRuntime", "JSContext *")}}</td>
   <td>The context to configure. {{ Jsapi-requires-request() }}</td>
  </tr>
  <tr>
   <td><code>key</code></td>
   <td><code>JSGCParamKey</code></td>
   <td>Specifies which garbage collection parameter to get or set.</td>
  </tr>
  <tr>
   <td><code>value</code></td>
   <td><code>uint32_t</code></td>
   <td><em>(<code>JS_SetGCParameter</code> only)</em> The value to assign to the parameter.</td>
  </tr>
 </tbody>
</table>

<pre class="brush: cpp">typedef enum JSGCParamKey {
    JSGC_MAX_BYTES,
    JSGC_MAX_MALLOC_BYTES,
    JSGC_MAX_NURSERY_BYTES,
    JSGC_BYTES,
    JSGC_NUMBER,
    JSGC_MODE,
    JSGC_UNUSED_CHUNKS,
    JSGC_TOTAL_CHUNKS,
    JSGC_SLICE_TIME_BUDGET,
    JSGC_MARK_STACK_LIMIT,
    JSGC_HIGH_FREQUENCY_TIME_LIMIT,
    JSGC_HIGH_FREQUENCY_LOW_LIMIT,
    JSGC_HIGH_FREQUENCY_HIGH_LIMIT,
    JSGC_HIGH_FREQUENCY_HEAP_GROWTH_MAX,
    JSGC_HIGH_FREQUENCY_HEAP_GROWTH_MIN,
    JSGC_LOW_FREQUENCY_HEAP_GROWTH,
    JSGC_DYNAMIC_HEAP_GROWTH,
    JSGC_DYNAMIC_MARK_SLICE,
    JSGC_ALLOCATION_THRESHOLD,
    JSGC_MIN_EMPTY_CHUNK_COUNT,
    JSGC_MAX_EMPTY_CHUNK_COUNT,
    JSGC_COMPACTION_ENABLED,
    JSGC_ALLOCATION_THRESHOLD_FACTOR,
    JSGC_ALLOCATION_THRESHOLD_FACTOR_AVOID_INTERRUPT,
    JSGC_NURSERY_FREE_THRESHOLD_FOR_IDLE_COLLECTION,
    JSGC_PRETENURE_THRESHOLD,
    JSGC_PRETENURE_GROUP_THRESHOLD,
    JSGC_NURSERY_FREE_THRESHOLD_FOR_IDLE_COLLECTION_PERCENT,
    JSGC_MIN_NURSERY_BYTES,
    JSGC_MIN_LAST_DITCH_GC_PERIOD,
} JSGCParamKey;
</pre>

<table class="fullwidth-table">
 <tbody>
  <tr>
   <th>Value (C++/JS Shell)</th>
   <th>Description</th>
  </tr>
  <tr>
   <td><code>JSGC_MAX_BYTES</code> / <code>"maxBytes"</code></td>
   <td>Maximum nominal heap before last ditch GC.</td>
  </tr>
  <tr>
   <td><code>JSGC_MAX_MALLOC_BYTES</code> / <code>"maxMallocBytes"</code></td>
   <td>Number of JS_malloc bytes before last ditch GC.</td>
  </tr>
  <tr>
   <td><code>JSGC_MAX_NURSERY_BYTES</code> / <code>"maxNurseryBytes"</code></td>
   <td>Maximum size the nursery may grow to, or 0 to disable generational GC.</td>
  </tr>
  <tr>
   <td><code>JSGC_MIN_NURSERY_BYTES</code> / <code>"minNurseryBytes"</code></td>
   <td>Minimum size the nursery may shrink to.</td>
  </tr>
  <tr>
   <td><code>JSGC_BYTES</code> / <code>"gcBytes"</code></td>
   <td>Amount of bytes allocated by the GC.</td>
  </tr>
  <tr>
   <td><code>JSGC_NUMBER</code> / <code>"gcNumber"</code></td>
   <td>Number of times GC has been invoked. Includes both major and minor GC.</td>
  </tr>
  <tr>
   <td><code>JSGC_MODE</code> / <code>"mode"</code></td>
   <td>
    <p>Select GC mode:</p>

    <dl>
     <dt><code>JSGC_MODE_GLOBAL</code> (0)</dt>
     <dd>The GC runs all objects are visited in a single<em>slice</em>.</dd>
     <dt><code>JSGC_MODE_ZONE</code> (1)</dt>
     <dd>The GC runs only the objects that belong to some<em>zones</em> are visited in a single<em>slice</em>.</dd>
     <dt><code>JSGC_MODE_INCREMENTAL</code> (2)</dt>
     <dd>The GC runs all objects are visited in multiple<em>slices</em>.</dd>
     <dt><code>JSGC_MODE_ZONE_INCREMENTAL</code> (3)</dt>
     <dd>The GC runs only the objects that belong to some<em>zones</em> are visited in multiple<em>slices</em>.</dd>
    </dl>

    <p>This does not affect generational GC, see <code>JSGC_MAX_NURSERY_BYTES</code></p>
   </td>
  </tr>
  <tr>
   <td><code>JSGC_UNUSED_CHUNKS</code> / <code>"unusedChunks"</code></td>
   <td>Number of cached empty GC chunks.</td>
  </tr>
  <tr>
   <td><code>JSGC_TOTAL_CHUNKS</code> / <code>"totalChunks"</code></td>
   <td>Total number of allocated GC chunks.</td>
  </tr>
  <tr>
   <td><code>JSGC_SLICE_TIME_BUDGET</code> / <code>"sliceTimeBudget"</code></td>
   <td>Max milliseconds to spend in an incremental GC slice. 0 for infinite.</td>
  </tr>
  <tr>
   <td><code>JSGC_MARK_STACK_LIMIT</code> / <code>"markStackLimit"</code></td>
   <td>Maximum size the GC mark stack can grow to (units: entries).</td>
  </tr>
  <tr>
   <td><code>JSGC_HIGH_FREQUENCY_TIME_LIMIT</code> / <code>"highFrequencyTimeLimit"</code></td>
   <td>GCs less than this far apart in time will be considered 'high-frequency GCs'.</td>
  </tr>
  <tr>
   <td><code>JSGC_HIGH_FREQUENCY_LOW_LIMIT</code> / <code>"highFrequencyLowLimit"</code></td>
   <td rowspan="4">
    <p>Controls for dynamic heap growth. When the GC is in "high frequency" mode (see above) then, the heap will be allowed to grow between collections according to these four parameters. See ZoneHeapThreshold::computeZoneHeapGrowthFactorForHeapSize in GC.cpp for the details.</p>

    <p>The first two parameters are in MB and the remaining two are in percentage of heap size.</p>
   </td>
  </tr>
  <tr>
   <td><code>JSGC_HIGH_FREQUENCY_HIGH_LIMIT</code> / <code>"highFrequencyHighLimit"</code></td>
  </tr>
  <tr>
   <td><code>JSGC_HIGH_FREQUENCY_HEAP_GROWTH_MAX</code> / <code>"highFrequencyHeapGrowthMax"</code></td>
  </tr>
  <tr>
   <td><code>JSGC_HIGH_FREQUENCY_HEAP_GROWTH_MIN</code> / <code>"highFrequencyHeapGrowthMin"</code></td>
  </tr>
  <tr>
   <td><code>JSGC_LOW_FREQUENCY_HEAP_GROWTH</code> / <code>"lowFrequencyHeapGrowth"</code></td>
   <td>Heap growth percentage for low frequency GCs.</td>
  </tr>
  <tr>
   <td><code>JSGC_DYNAMIC_HEAP_GROWTH</code> / <code>"dynamicHeapGrowth"</code></td>
   <td>If false, the heap growth percentage is fixed at 300%. If true, it is determined based on whether GCs are high- or low- frequency.</td>
  </tr>
  <tr>
   <td><code>JSGC_DYNAMIC_MARK_SLICE</code> / <code>"dynamicMarkSlice"</code></td>
   <td>If true, high-frequency GCs will use a longer mark slice.</td>
  </tr>
  <tr>
   <td><code>JSGC_ALLOCATION_THRESHOLD</code> / <code>"allocationThreshold"</code></td>
   <td>Lower limit after which we limit the heap growth. The heap will be collected if it is greater than: <code>MAX(allocThreshold, lastSize) * thresholdFactor</code>, This establishes allocThreshold as a baseline or default heap size.</td>
  </tr>
  <tr>
   <td><code>JSGC_ALLOCATION_THRESHOLD_FACTOR</code> / <code>"allocationThresholdFactor"</code></td>
   <td rowspan="2">
    <p>These thresholds (as percentages) are compared with the zone threshold (above) to decide when to begin an incremental collection. <code>JSGC_ALLOCATION_THRESHOLD_FACTOR_AVOID_INTERRUPT</code> is used when a GC is already in progress for other zones and we may wish to avoid interrupting it.</p>

    <p>Additionally if a zone expands beyond the threshold without this factor, then it will be collected non-incrementally</p>
   </td>
  </tr>
  <tr>
   <td><code>JSGC_ALLOCATION_THRESHOLD_FACTOR_AVOID_INTERRUPT</code> / <code>"allocationThresholdfactorAvoidInterrupt"</code></td>
  </tr>
  <tr>
   <td><code>JSGC_MIN_EMPTY_CHUNK_COUNT</code> / <code>"minEmptyChunkCount"</code></td>
   <td>We try to keep at least this many unused chunks in the free chunk pool at all times, even after a shrinking GC.</td>
  </tr>
  <tr>
   <td><code>JSGC_MAX_EMPTY_CHUNK_COUNT</code> / <code>"maxEmptyChunkCount"</code></td>
   <td>We never keep more than this many unused chunks in the free chunk pool.</td>
  </tr>
  <tr>
   <td><code>JSGC_COMPACTION_ENABLED</code> / <code>"compactingEnabled"</code></td>
   <td>non-zero to enable compacting, zero to disable.</td>
  </tr>
  <tr>
   <td><code>JSGC_NURSERY_FREE_THRESHOLD_FOR_IDLE_COLLECTION</code> / <code>"nurseryFreeThresholdForIdleCollection"</code></td>
   <td>Collect the nursery in idle time if it has less than this many bytes of free space.</td>
  </tr>
  <tr>
   <td><code>JSGC_NURSERY_FREE_THRESHOLD_FOR_IDLE_COLLECTION_PERCENT</code> / <code>"nurseryFreeThresholdForIdleCollectionPercent"</code></td>
   <td>Collect the nursery in idle time if it has less than this percentage of capacity free (value from 0 - 99).</td>
  </tr>
  <tr>
   <td><code>JSGC_PRETENURE_THRESHOLD</code> / <code>"pretenureThreshold"</code></td>
   <td>If this percentage of the nursery is tenured and the nursery is at least 4MB, then process object groups to look for pretenuring candidates.</td>
  </tr>
  <tr>
   <td><code>JSGC_PRETENURE_GROUP_THRESHOLD</code> / <code>"pretenureGroupThreshold"</code></td>
   <td>If more than this number of objects in a given object group are tenured, then pretenruing will be enabled for new objects in this group.</td>
  </tr>
  <tr>
   <td><code>JSGC_MIN_LAST_DITCH_GC_PERIOD</code> / <code>"minLastDitchGCPeriod"</code></td>
   <td>The minimum time to allow between triggering last ditch GCs in seconds.</td>
  </tr>
 </tbody>
</table>

<h2 id="Description" name="Description">説明</h2>

<p><code>JS_GetGCParameter</code> returns the current parameter of the garbage collection.</p>

<p>If successful, <code>JS_GetGCParameter</code> returns the current parameter.</p>

<p><code>JS_SetGCParameter</code> ajusts the parameter of the garbage collection.</p>

<h2 id="See_Also" name="See_Also">あわせて参照</h2>

<ul>
 <li>{{ LXRSearch("ident", "i", "JS_GetGCParameter") }}</li>
 <li>{{ LXRSearch("ident", "i", "JS_SetGCParameter") }}</li>
 <li>{{bug(474801)}}
  <ul>
   <li><code>JSGC_BYTES</code></li>
   <li><code>JSGC_NUMBER</code></li>
  </ul>
 </li>
 <li>{{bug(474497)}}
  <ul>
   <li><code>JSGC_MAX_CODE_CACHE_BYTES</code></li>
   <li>This option no-longer exists</li>
   <li><code>JS_GetGCParameterForThread</code></li>
   <li><code>JS_SetGCParameterForThread</code></li>
  </ul>
 </li>
 <li>{{bug(624229)}}
  <ul>
   <li><code>JSGC_MODE</code></li>
  </ul>
 </li>
 <li>{{bug(631733)}}
  <ul>
   <li><code>JSGC_UNUSED_CHUNKS</code></li>
  </ul>
 </li>
 <li>{{bug(674480)}}
  <ul>
   <li><code>JSGC_TOTAL_CHUNKS</code></li>
  </ul>
 </li>
 <li>{{bug(641025)}}
  <ul>
   <li><code>JSGC_SLICE_TIME_BUDGET</code></li>
  </ul>
 </li>
 <li>{{bug(673551)}}
  <ul>
   <li><code>JSGC_MARK_STACK_LIMIT</code></li>
  </ul>
 </li>
 <li>{{bug(765435)}}
  <ul>
   <li><code>JSGC_HIGH_FREQUENCY_TIME_LIMIT</code></li>
   <li><code>JSGC_HIGH_FREQUENCY_LOW_LIMIT</code></li>
   <li><code>JSGC_HIGH_FREQUENCY_HIGH_LIMIT</code></li>
   <li><code>JSGC_HIGH_FREQUENCY_HEAP_GROWTH_MAX</code></li>
   <li><code>JSGC_HIGH_FREQUENCY_HEAP_GROWTH_MIN</code></li>
   <li><code>JSGC_LOW_FREQUENCY_HEAP_GROWTH</code></li>
   <li><code>JSGC_DYNAMIC_HEAP_GROWTH</code></li>
   <li><code>JSGC_DYNAMIC_MARK_SLICE</code></li>
  </ul>
 </li>
 <li>{{bug(800063)}}
  <ul>
   <li><code>JSGC_ALLOCATION_THRESHOLD</code></li>
  </ul>
 </li>
 <li>{{bug(871005)}}
  <ul>
   <li><code>JSGC_DECOMMIT_THRESHOLD</code></li>
   <li>This option is no-longer exists</li>
  </ul>
 </li>
 <li>{{bug(1017141)}}
  <ul>
   <li><code>JSGC_MIN_EMPTY_CHUNK_COUNT</code></li>
   <li><code>JSGC_MAX_EMPTY_CHUNK_COUNT</code></li>
  </ul>
 </li>
</ul>