rbs 3.9.5 → 3.10.0.pre.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.clang-format +74 -0
- data/.clangd +2 -0
- data/.github/workflows/c-check.yml +54 -0
- data/.github/workflows/comments.yml +3 -3
- data/.github/workflows/ruby.yml +34 -19
- data/.github/workflows/typecheck.yml +1 -1
- data/.github/workflows/windows.yml +1 -1
- data/.gitignore +4 -0
- data/README.md +38 -1
- data/Rakefile +152 -23
- data/config.yml +190 -62
- data/core/array.rbs +44 -43
- data/core/dir.rbs +2 -2
- data/core/encoding.rbs +3 -2
- data/core/enumerable.rbs +89 -2
- data/core/errno.rbs +8 -0
- data/core/errors.rbs +28 -1
- data/core/exception.rbs +2 -2
- data/core/fiber.rbs +3 -3
- data/core/file.rbs +26 -11
- data/core/float.rbs +1 -1
- data/core/gc.rbs +422 -281
- data/core/hash.rbs +1024 -727
- data/core/io/wait.rbs +11 -33
- data/core/io.rbs +6 -4
- data/core/kernel.rbs +49 -43
- data/core/marshal.rbs +1 -1
- data/core/match_data.rbs +1 -1
- data/core/math.rbs +42 -3
- data/core/method.rbs +14 -6
- data/core/module.rbs +71 -11
- data/core/nil_class.rbs +3 -3
- data/core/numeric.rbs +8 -8
- data/core/object.rbs +3 -3
- data/core/object_space.rbs +13 -0
- data/{stdlib/pathname/0 → core}/pathname.rbs +253 -352
- data/core/proc.rbs +15 -8
- data/core/process.rbs +2 -2
- data/core/ractor.rbs +278 -437
- data/core/range.rbs +6 -7
- data/core/rbs/unnamed/argf.rbs +1 -1
- data/core/rbs/unnamed/env_class.rbs +1 -1
- data/core/rbs/unnamed/random.rbs +4 -2
- data/core/regexp.rbs +22 -17
- data/core/ruby_vm.rbs +6 -4
- data/core/rubygems/errors.rbs +3 -70
- data/core/rubygems/rubygems.rbs +11 -79
- data/core/set.rbs +439 -332
- data/core/string.rbs +2897 -1117
- data/core/struct.rbs +1 -1
- data/core/symbol.rbs +4 -4
- data/core/thread.rbs +83 -20
- data/core/time.rbs +35 -9
- data/core/unbound_method.rbs +14 -6
- data/docs/aliases.md +79 -0
- data/docs/collection.md +2 -2
- data/docs/gem.md +0 -1
- data/docs/sigs.md +3 -3
- data/ext/rbs_extension/ast_translation.c +1016 -0
- data/ext/rbs_extension/ast_translation.h +37 -0
- data/ext/rbs_extension/class_constants.c +157 -0
- data/{include/rbs/constants.h → ext/rbs_extension/class_constants.h} +7 -1
- data/ext/rbs_extension/compat.h +10 -0
- data/ext/rbs_extension/extconf.rb +25 -1
- data/ext/rbs_extension/legacy_location.c +317 -0
- data/ext/rbs_extension/legacy_location.h +45 -0
- data/ext/rbs_extension/main.c +365 -14
- data/ext/rbs_extension/rbs_extension.h +6 -21
- data/ext/rbs_extension/rbs_string_bridging.c +9 -0
- data/ext/rbs_extension/rbs_string_bridging.h +24 -0
- data/include/rbs/ast.h +687 -0
- data/include/rbs/defines.h +86 -0
- data/include/rbs/lexer.h +199 -0
- data/include/rbs/location.h +59 -0
- data/include/rbs/parser.h +135 -0
- data/include/rbs/string.h +49 -0
- data/include/rbs/util/rbs_allocator.h +59 -0
- data/include/rbs/util/rbs_assert.h +20 -0
- data/include/rbs/util/rbs_buffer.h +83 -0
- data/include/rbs/util/rbs_constant_pool.h +6 -67
- data/include/rbs/util/rbs_encoding.h +282 -0
- data/include/rbs/util/rbs_unescape.h +23 -0
- data/include/rbs.h +1 -2
- data/lib/rbs/annotate/formatter.rb +3 -13
- data/lib/rbs/annotate/rdoc_annotator.rb +3 -1
- data/lib/rbs/annotate/rdoc_source.rb +1 -1
- data/lib/rbs/cli/validate.rb +2 -2
- data/lib/rbs/cli.rb +1 -1
- data/lib/rbs/collection/config/lockfile_generator.rb +1 -0
- data/lib/rbs/definition_builder/ancestor_builder.rb +5 -5
- data/lib/rbs/environment.rb +64 -59
- data/lib/rbs/environment_loader.rb +1 -1
- data/lib/rbs/errors.rb +1 -1
- data/lib/rbs/parser_aux.rb +5 -0
- data/lib/rbs/resolver/constant_resolver.rb +2 -2
- data/lib/rbs/resolver/type_name_resolver.rb +124 -38
- data/lib/rbs/test/type_check.rb +13 -0
- data/lib/rbs/types.rb +3 -1
- data/lib/rbs/version.rb +1 -1
- data/lib/rbs.rb +1 -1
- data/lib/rdoc/discover.rb +1 -1
- data/lib/rdoc_plugin/parser.rb +3 -3
- data/sig/annotate/formatter.rbs +2 -2
- data/sig/annotate/rdoc_annotater.rbs +1 -1
- data/sig/environment.rbs +57 -6
- data/sig/manifest.yaml +0 -1
- data/sig/parser.rbs +20 -0
- data/sig/resolver/type_name_resolver.rbs +38 -7
- data/sig/types.rbs +4 -1
- data/src/ast.c +1256 -0
- data/src/lexer.c +2956 -0
- data/src/lexer.re +147 -0
- data/src/lexstate.c +205 -0
- data/src/location.c +71 -0
- data/src/parser.c +3495 -0
- data/src/string.c +90 -0
- data/src/util/rbs_allocator.c +152 -0
- data/src/util/rbs_assert.c +21 -0
- data/src/util/rbs_buffer.c +54 -0
- data/src/util/rbs_constant_pool.c +16 -86
- data/src/util/rbs_encoding.c +21308 -0
- data/src/util/rbs_unescape.c +131 -0
- data/stdlib/cgi/0/core.rbs +2 -396
- data/stdlib/cgi/0/manifest.yaml +1 -0
- data/stdlib/cgi-escape/0/escape.rbs +153 -0
- data/stdlib/coverage/0/coverage.rbs +3 -1
- data/stdlib/delegate/0/delegator.rbs +10 -7
- data/stdlib/erb/0/erb.rbs +737 -347
- data/stdlib/fileutils/0/fileutils.rbs +18 -13
- data/stdlib/forwardable/0/forwardable.rbs +3 -0
- data/stdlib/json/0/json.rbs +67 -48
- data/stdlib/net-http/0/net-http.rbs +3 -0
- data/stdlib/objspace/0/objspace.rbs +8 -3
- data/stdlib/open-uri/0/open-uri.rbs +40 -0
- data/stdlib/openssl/0/openssl.rbs +182 -149
- data/stdlib/optparse/0/optparse.rbs +3 -3
- data/stdlib/rdoc/0/code_object.rbs +2 -2
- data/stdlib/rdoc/0/comment.rbs +2 -0
- data/stdlib/rdoc/0/options.rbs +76 -0
- data/stdlib/rdoc/0/rdoc.rbs +7 -5
- data/stdlib/rdoc/0/store.rbs +1 -1
- data/stdlib/resolv/0/resolv.rbs +25 -68
- data/stdlib/ripper/0/ripper.rbs +5 -2
- data/stdlib/singleton/0/singleton.rbs +3 -0
- data/stdlib/socket/0/socket.rbs +13 -1
- data/stdlib/socket/0/tcp_socket.rbs +10 -2
- data/stdlib/stringio/0/stringio.rbs +412 -80
- data/stdlib/strscan/0/string_scanner.rbs +31 -31
- data/stdlib/tempfile/0/tempfile.rbs +1 -1
- data/stdlib/tsort/0/cyclic.rbs +3 -0
- data/stdlib/uri/0/common.rbs +11 -2
- data/stdlib/uri/0/file.rbs +1 -1
- data/stdlib/uri/0/generic.rbs +16 -15
- data/stdlib/uri/0/rfc2396_parser.rbs +6 -7
- data/stdlib/zlib/0/zstream.rbs +1 -0
- metadata +41 -18
- data/ext/rbs_extension/lexer.c +0 -2728
- data/ext/rbs_extension/lexer.h +0 -179
- data/ext/rbs_extension/lexer.re +0 -147
- data/ext/rbs_extension/lexstate.c +0 -175
- data/ext/rbs_extension/location.c +0 -325
- data/ext/rbs_extension/location.h +0 -85
- data/ext/rbs_extension/parser.c +0 -2982
- data/ext/rbs_extension/parser.h +0 -18
- data/ext/rbs_extension/parserstate.c +0 -411
- data/ext/rbs_extension/parserstate.h +0 -163
- data/ext/rbs_extension/unescape.c +0 -32
- data/include/rbs/ruby_objs.h +0 -72
- data/src/constants.c +0 -153
- data/src/ruby_objs.c +0 -799
data/core/gc.rbs
CHANGED
|
@@ -160,81 +160,65 @@ module GC
|
|
|
160
160
|
# <!--
|
|
161
161
|
# rdoc-file=gc.rb
|
|
162
162
|
# - GC.config -> hash
|
|
163
|
-
# - GC.config(
|
|
163
|
+
# - GC.config(hash_to_merge) -> hash
|
|
164
164
|
# -->
|
|
165
|
-
#
|
|
165
|
+
# This method is implementation-specific to CRuby.
|
|
166
|
+
#
|
|
167
|
+
# Sets or gets information about the current GC configuration.
|
|
166
168
|
#
|
|
167
169
|
# Configuration parameters are GC implementation-specific and may change without
|
|
168
170
|
# notice.
|
|
169
171
|
#
|
|
170
|
-
#
|
|
171
|
-
# a `Hash` with `Symbol` keys.
|
|
172
|
-
#
|
|
173
|
-
# This method can also be called with a `Hash` argument to assign values to
|
|
174
|
-
# valid config keys. Config keys missing from the passed `Hash` will be left
|
|
175
|
-
# unmodified.
|
|
176
|
-
#
|
|
177
|
-
# If a key/value pair is passed to this function that does not correspond to a
|
|
178
|
-
# valid config key for the GC implementation being used, no config will be
|
|
179
|
-
# updated, the key will be present in the returned Hash, and its value will be
|
|
180
|
-
# `nil`. This is to facilitate easy migration between GC implementations.
|
|
181
|
-
#
|
|
182
|
-
# In both call-seqs, the return value of `GC.config` will be a `Hash` containing
|
|
183
|
-
# the most recent full configuration, i.e., all keys and values defined by the
|
|
184
|
-
# specific GC implementation being used. In the case of a config update, the
|
|
185
|
-
# return value will include the new values being updated.
|
|
186
|
-
#
|
|
187
|
-
# This method is only expected to work on CRuby.
|
|
172
|
+
# With no argument given, returns a hash containing the configuration:
|
|
188
173
|
#
|
|
189
|
-
#
|
|
174
|
+
# GC.config
|
|
175
|
+
# # => {rgengc_allow_full_mark: true, implementation: "default"}
|
|
190
176
|
#
|
|
191
|
-
#
|
|
192
|
-
#
|
|
193
|
-
# attempting to write to them will raise `ArgumentError`.
|
|
177
|
+
# With argument `hash_to_merge` given, merges that hash into the stored
|
|
178
|
+
# configuration hash; ignores unknown hash keys; returns the configuration hash:
|
|
194
179
|
#
|
|
195
|
-
#
|
|
180
|
+
# GC.config(rgengc_allow_full_mark: false)
|
|
181
|
+
# # => {rgengc_allow_full_mark: false, implementation: "default"}
|
|
182
|
+
# GC.config(foo: 'bar')
|
|
183
|
+
# # => {rgengc_allow_full_mark: false, implementation: "default"}
|
|
196
184
|
#
|
|
197
|
-
#
|
|
198
|
-
# : Returns a `String` containing the name of the currently loaded GC library,
|
|
199
|
-
# if one has been loaded using `RUBY_GC_LIBRARY`, and "default" in all other
|
|
200
|
-
# cases
|
|
185
|
+
# **All-Implementations Configuration**
|
|
201
186
|
#
|
|
187
|
+
# The single read-only entry for all implementations is:
|
|
202
188
|
#
|
|
203
|
-
#
|
|
189
|
+
# * `:implementation`: the string name of the implementation; for the Ruby
|
|
190
|
+
# default implementation, `'default'`.
|
|
204
191
|
#
|
|
205
|
-
#
|
|
206
|
-
# Ruby's default GC implementation are:
|
|
192
|
+
# **Implementation-Specific Configuration**
|
|
207
193
|
#
|
|
208
|
-
#
|
|
209
|
-
# : Controls whether the GC is allowed to run a full mark (young & old
|
|
210
|
-
# objects).
|
|
194
|
+
# A GC implementation maintains its own implementation-specific configuration.
|
|
211
195
|
#
|
|
212
|
-
#
|
|
213
|
-
# default. GC will function as intended.
|
|
196
|
+
# For Ruby's default implementation the single entry is:
|
|
214
197
|
#
|
|
215
|
-
#
|
|
216
|
-
#
|
|
217
|
-
# run—only young objects will be marked. When the heap space is exhausted,
|
|
218
|
-
# new pages will be allocated immediately instead of running a full mark.
|
|
198
|
+
# * `:rgengc_allow_full_mark`: Controls whether the GC is allowed to run a
|
|
199
|
+
# full mark (young & old objects):
|
|
219
200
|
#
|
|
220
|
-
#
|
|
221
|
-
#
|
|
222
|
-
#
|
|
223
|
-
#
|
|
224
|
-
#
|
|
225
|
-
#
|
|
226
|
-
#
|
|
227
|
-
#
|
|
228
|
-
# `Process.warmup` before setting this parameter to `false`.
|
|
201
|
+
# * `true` (default): GC interleaves major and minor collections. A flag
|
|
202
|
+
# is set to notify GC that a full mark has been requested. This flag is
|
|
203
|
+
# accessible via GC.latest_gc_info(:need_major_by).
|
|
204
|
+
# * `false`: GC does not initiate a full marking cycle unless explicitly
|
|
205
|
+
# directed by user code; see GC.start. Setting this parameter to `false`
|
|
206
|
+
# disables young-to-old promotion. For performance reasons, we
|
|
207
|
+
# recommended warming up the application using Process.warmup before
|
|
208
|
+
# setting this parameter to `false`.
|
|
229
209
|
#
|
|
230
210
|
def self.config: () -> Hash[Symbol, untyped]
|
|
231
211
|
| (Hash[Symbol, untyped]) -> Hash[Symbol, untyped]
|
|
232
212
|
|
|
233
213
|
# <!--
|
|
234
214
|
# rdoc-file=gc.rb
|
|
235
|
-
# -
|
|
215
|
+
# - self.count -> integer
|
|
236
216
|
# -->
|
|
237
|
-
# Returns the number of times
|
|
217
|
+
# Returns the total number of times garbage collection has occurred:
|
|
218
|
+
#
|
|
219
|
+
# GC.count # => 385
|
|
220
|
+
# GC.start
|
|
221
|
+
# GC.count # => 386
|
|
238
222
|
#
|
|
239
223
|
def self.count: () -> Integer
|
|
240
224
|
|
|
@@ -242,11 +226,12 @@ module GC
|
|
|
242
226
|
# rdoc-file=gc.rb
|
|
243
227
|
# - GC.disable -> true or false
|
|
244
228
|
# -->
|
|
245
|
-
# Disables garbage collection
|
|
246
|
-
# already disabled.
|
|
229
|
+
# Disables garbage collection (but GC.start remains potent): returns whether
|
|
230
|
+
# garbage collection was already disabled.
|
|
247
231
|
#
|
|
248
|
-
# GC.
|
|
249
|
-
# GC.disable
|
|
232
|
+
# GC.enable
|
|
233
|
+
# GC.disable # => false
|
|
234
|
+
# GC.disable # => true
|
|
250
235
|
#
|
|
251
236
|
def self.disable: () -> bool
|
|
252
237
|
|
|
@@ -254,12 +239,11 @@ module GC
|
|
|
254
239
|
# rdoc-file=gc.rb
|
|
255
240
|
# - GC.enable -> true or false
|
|
256
241
|
# -->
|
|
257
|
-
# Enables garbage collection
|
|
258
|
-
# previously disabled.
|
|
242
|
+
# Enables garbage collection; returns whether garbage collection was disabled:
|
|
259
243
|
#
|
|
260
|
-
# GC.disable
|
|
261
|
-
# GC.enable
|
|
262
|
-
# GC.enable
|
|
244
|
+
# GC.disable
|
|
245
|
+
# GC.enable # => true
|
|
246
|
+
# GC.enable # => false
|
|
263
247
|
#
|
|
264
248
|
def self.enable: () -> bool
|
|
265
249
|
|
|
@@ -267,161 +251,194 @@ module GC
|
|
|
267
251
|
# rdoc-file=gc.rb
|
|
268
252
|
# - start(full_mark: true, immediate_mark: true, immediate_sweep: true)
|
|
269
253
|
# -->
|
|
270
|
-
# Initiates garbage collection, even if
|
|
271
|
-
#
|
|
272
|
-
# The `full_mark` keyword argument determines whether or not to perform a major
|
|
273
|
-
# garbage collection cycle. When set to `true`, a major garbage collection cycle
|
|
274
|
-
# is run, meaning all objects are marked. When set to `false`, a minor garbage
|
|
275
|
-
# collection cycle is run, meaning only young objects are marked.
|
|
276
|
-
#
|
|
277
|
-
# The `immediate_mark` keyword argument determines whether or not to perform
|
|
278
|
-
# incremental marking. When set to `true`, marking is completed during the call
|
|
279
|
-
# to this method. When set to `false`, marking is performed in steps that are
|
|
280
|
-
# interleaved with future Ruby code execution, so marking might not be completed
|
|
281
|
-
# during this method call. Note that if `full_mark` is `false`, then marking
|
|
282
|
-
# will always be immediate, regardless of the value of `immediate_mark`.
|
|
283
|
-
#
|
|
284
|
-
# The `immediate_sweep` keyword argument determines whether or not to defer
|
|
285
|
-
# sweeping (using lazy sweep). When set to `false`, sweeping is performed in
|
|
286
|
-
# steps that are interleaved with future Ruby code execution, so sweeping might
|
|
287
|
-
# not be completed during this method call. When set to `true`, sweeping is
|
|
288
|
-
# completed during the call to this method.
|
|
289
|
-
#
|
|
290
|
-
# Note: These keyword arguments are implementation and version-dependent. They
|
|
291
|
-
# are not guaranteed to be future-compatible and may be ignored if the
|
|
292
|
-
# underlying implementation does not support them.
|
|
293
|
-
#
|
|
294
|
-
def self.start: (?immediate_sweep: boolish, ?immediate_mark: boolish, ?full_mark: boolish) -> nil
|
|
295
|
-
|
|
296
|
-
# <!--
|
|
297
|
-
# rdoc-file=gc.rb
|
|
298
|
-
# - GC.stat -> Hash
|
|
299
|
-
# - GC.stat(hash) -> Hash
|
|
300
|
-
# - GC.stat(:key) -> Numeric
|
|
301
|
-
# -->
|
|
302
|
-
# Returns a Hash containing information about the GC.
|
|
303
|
-
#
|
|
304
|
-
# The contents of the hash are implementation-specific and may change in the
|
|
305
|
-
# future without notice.
|
|
306
|
-
#
|
|
307
|
-
# The hash includes internal statistics about GC such as:
|
|
308
|
-
#
|
|
309
|
-
# count
|
|
310
|
-
# : The total number of garbage collections run since application start (count
|
|
311
|
-
# includes both minor and major garbage collections)
|
|
312
|
-
#
|
|
313
|
-
# time
|
|
314
|
-
# : The total time spent in garbage collections (in milliseconds)
|
|
315
|
-
#
|
|
316
|
-
# heap_allocated_pages
|
|
317
|
-
# : The total number of `:heap_eden_pages` + `:heap_tomb_pages`
|
|
318
|
-
#
|
|
319
|
-
# heap_sorted_length
|
|
320
|
-
# : The number of pages that can fit into the buffer that holds references to
|
|
321
|
-
# all pages
|
|
322
|
-
#
|
|
323
|
-
# heap_allocatable_pages
|
|
324
|
-
# : The total number of pages the application could allocate without
|
|
325
|
-
# additional GC
|
|
326
|
-
#
|
|
327
|
-
# heap_available_slots
|
|
328
|
-
# : The total number of slots in all `:heap_allocated_pages`
|
|
329
|
-
#
|
|
330
|
-
# heap_live_slots
|
|
331
|
-
# : The total number of slots which contain live objects
|
|
332
|
-
#
|
|
333
|
-
# heap_free_slots
|
|
334
|
-
# : The total number of slots which do not contain live objects
|
|
335
|
-
#
|
|
336
|
-
# heap_final_slots
|
|
337
|
-
# : The total number of slots with pending finalizers to be run
|
|
338
|
-
#
|
|
339
|
-
# heap_marked_slots
|
|
340
|
-
# : The total number of objects marked in the last GC
|
|
341
|
-
#
|
|
342
|
-
# heap_eden_pages
|
|
343
|
-
# : The total number of pages which contain at least one live slot
|
|
344
|
-
#
|
|
345
|
-
# heap_tomb_pages
|
|
346
|
-
# : The total number of pages which do not contain any live slots
|
|
347
|
-
#
|
|
348
|
-
# total_allocated_pages
|
|
349
|
-
# : The cumulative number of pages allocated since application start
|
|
350
|
-
#
|
|
351
|
-
# total_freed_pages
|
|
352
|
-
# : The cumulative number of pages freed since application start
|
|
353
|
-
#
|
|
354
|
-
# total_allocated_objects
|
|
355
|
-
# : The cumulative number of objects allocated since application start
|
|
356
|
-
#
|
|
357
|
-
# total_freed_objects
|
|
358
|
-
# : The cumulative number of objects freed since application start
|
|
359
|
-
#
|
|
360
|
-
# malloc_increase_bytes
|
|
361
|
-
# : Amount of memory allocated on the heap for objects. Decreased by any GC
|
|
362
|
-
#
|
|
363
|
-
# malloc_increase_bytes_limit
|
|
364
|
-
# : When `:malloc_increase_bytes` crosses this limit, GC is triggered
|
|
365
|
-
#
|
|
366
|
-
# minor_gc_count
|
|
367
|
-
# : The total number of minor garbage collections run since process start
|
|
368
|
-
#
|
|
369
|
-
# major_gc_count
|
|
370
|
-
# : The total number of major garbage collections run since process start
|
|
371
|
-
#
|
|
372
|
-
# compact_count
|
|
373
|
-
# : The total number of compactions run since process start
|
|
374
|
-
#
|
|
375
|
-
# read_barrier_faults
|
|
376
|
-
# : The total number of times the read barrier was triggered during compaction
|
|
377
|
-
#
|
|
378
|
-
# total_moved_objects
|
|
379
|
-
# : The total number of objects compaction has moved
|
|
254
|
+
# Initiates garbage collection, even if explicitly disabled by GC.disable.
|
|
380
255
|
#
|
|
381
|
-
#
|
|
382
|
-
# : The total number of objects without write barriers
|
|
256
|
+
# Keyword arguments:
|
|
383
257
|
#
|
|
384
|
-
#
|
|
385
|
-
# :
|
|
386
|
-
# triggered
|
|
258
|
+
# * `full_mark`: its boolean value determines whether to perform a major
|
|
259
|
+
# garbage collection cycle:
|
|
387
260
|
#
|
|
388
|
-
#
|
|
389
|
-
#
|
|
390
|
-
#
|
|
261
|
+
# * `true`: initiates a major garbage collection cycle, meaning all
|
|
262
|
+
# objects (old and new) are marked.
|
|
263
|
+
# * `false`: initiates a minor garbage collection cycle, meaning only
|
|
264
|
+
# young objects are marked.
|
|
391
265
|
#
|
|
392
|
-
#
|
|
393
|
-
# :
|
|
266
|
+
# * `immediate_mark`: its boolean value determines whether to perform
|
|
267
|
+
# incremental marking:
|
|
394
268
|
#
|
|
395
|
-
#
|
|
396
|
-
#
|
|
269
|
+
# * `true`: marking is completed before the method returns.
|
|
270
|
+
# * `false`: marking is performed by parts, interleaved with program
|
|
271
|
+
# execution both before the method returns and afterward; therefore
|
|
272
|
+
# marking may not be completed before the return. Note that if
|
|
273
|
+
# `full_mark` is `false`, marking will always be immediate, regardless
|
|
274
|
+
# of the value of `immediate_mark`.
|
|
397
275
|
#
|
|
398
|
-
#
|
|
399
|
-
# :
|
|
276
|
+
# * `immediate_sweep`: its boolean value determines whether to defer sweeping
|
|
277
|
+
# (using lazy sweep):
|
|
400
278
|
#
|
|
279
|
+
# * `true`: sweeping is completed before the method returns.
|
|
280
|
+
# * `false`: sweeping is performed by parts, interleaved with program
|
|
281
|
+
# execution both before the method returns and afterward; therefore
|
|
282
|
+
# sweeping may not be completed before the return.
|
|
401
283
|
#
|
|
402
|
-
#
|
|
403
|
-
#
|
|
284
|
+
# Note that these keword arguments are implementation- and version-dependent,
|
|
285
|
+
# are not guaranteed to be future-compatible, and may be ignored in some
|
|
286
|
+
# implementations.
|
|
404
287
|
#
|
|
405
|
-
|
|
288
|
+
def self.start: (?immediate_sweep: boolish, ?immediate_mark: boolish, ?full_mark: boolish) -> nil
|
|
289
|
+
|
|
290
|
+
# <!--
|
|
291
|
+
# rdoc-file=gc.rb
|
|
292
|
+
# - GC.stat -> new_hash
|
|
293
|
+
# - GC.stat(key) -> value
|
|
294
|
+
# - GC.stat(hash) -> hash
|
|
295
|
+
# -->
|
|
296
|
+
# This method is implementation-specific to CRuby.
|
|
297
|
+
#
|
|
298
|
+
# Returns GC statistics. The particular statistics are implementation-specific
|
|
299
|
+
# and may change in the future without notice.
|
|
300
|
+
#
|
|
301
|
+
# With no argument given, returns information about the most recent garbage
|
|
302
|
+
# collection:
|
|
303
|
+
#
|
|
304
|
+
# GC.stat
|
|
305
|
+
# # =>
|
|
306
|
+
# {count: 28,
|
|
307
|
+
# time: 1,
|
|
308
|
+
# marking_time: 1,
|
|
309
|
+
# sweeping_time: 0,
|
|
310
|
+
# heap_allocated_pages: 521,
|
|
311
|
+
# heap_empty_pages: 0,
|
|
312
|
+
# heap_allocatable_slots: 0,
|
|
313
|
+
# heap_available_slots: 539590,
|
|
314
|
+
# heap_live_slots: 422243,
|
|
315
|
+
# heap_free_slots: 117347,
|
|
316
|
+
# heap_final_slots: 0,
|
|
317
|
+
# heap_marked_slots: 264877,
|
|
318
|
+
# heap_eden_pages: 521,
|
|
319
|
+
# total_allocated_pages: 521,
|
|
320
|
+
# total_freed_pages: 0,
|
|
321
|
+
# total_allocated_objects: 2246376,
|
|
322
|
+
# total_freed_objects: 1824133,
|
|
323
|
+
# malloc_increase_bytes: 50982,
|
|
324
|
+
# malloc_increase_bytes_limit: 18535172,
|
|
325
|
+
# minor_gc_count: 18,
|
|
326
|
+
# major_gc_count: 10,
|
|
327
|
+
# compact_count: 0,
|
|
328
|
+
# read_barrier_faults: 0,
|
|
329
|
+
# total_moved_objects: 0,
|
|
330
|
+
# remembered_wb_unprotected_objects: 0,
|
|
331
|
+
# remembered_wb_unprotected_objects_limit: 2162,
|
|
332
|
+
# old_objects: 216365,
|
|
333
|
+
# old_objects_limit: 432540,
|
|
334
|
+
# oldmalloc_increase_bytes: 1654232,
|
|
335
|
+
# oldmalloc_increase_bytes_limit: 16846103}
|
|
336
|
+
#
|
|
337
|
+
# With symbol argument `key` given, returns the value for that key:
|
|
338
|
+
#
|
|
339
|
+
# GC.stat(:count) # => 30
|
|
340
|
+
#
|
|
341
|
+
# With hash argument `hash` given, returns that hash with GC statistics merged
|
|
342
|
+
# into its content; this form may be useful in minimizing [probe
|
|
343
|
+
# effects](https://en.wikipedia.org/wiki/Probe_effect):
|
|
344
|
+
#
|
|
345
|
+
# h = {foo: 0, bar: 1}
|
|
346
|
+
# GC.stat(h)
|
|
347
|
+
# h.keys.take(5) # => [:foo, :bar, :count, :time, :marking_time]
|
|
348
|
+
#
|
|
349
|
+
# The hash includes entries such as:
|
|
350
|
+
#
|
|
351
|
+
# * `:count`: The total number of garbage collections run since application
|
|
352
|
+
# start (count includes both minor and major garbage collections).
|
|
353
|
+
# * `:time`: The total time spent in garbage collections (in milliseconds).
|
|
354
|
+
# * `:heap_allocated_pages`: The total number of `:heap_eden_pages` +
|
|
355
|
+
# `:heap_tomb_pages`.
|
|
356
|
+
# * `:heap_sorted_length`: The number of pages that can fit into the buffer
|
|
357
|
+
# that holds references to all pages.
|
|
358
|
+
# * `:heap_allocatable_pages`: The total number of pages the application could
|
|
359
|
+
# allocate without additional GC.
|
|
360
|
+
# * `:heap_available_slots`: The total number of slots in all
|
|
361
|
+
# `:heap_allocated_pages`.
|
|
362
|
+
# * `:heap_live_slots`: The total number of slots which contain live objects.
|
|
363
|
+
# * `:heap_free_slots`: The total number of slots which do not contain live
|
|
364
|
+
# objects.
|
|
365
|
+
# * `:heap_final_slots`: The total number of slots with pending finalizers to
|
|
366
|
+
# be run.
|
|
367
|
+
# * `:heap_marked_slots`: The total number of objects marked in the last GC.
|
|
368
|
+
# * `:heap_eden_pages`: The total number of pages which contain at least one
|
|
369
|
+
# live slot.
|
|
370
|
+
# * `:heap_tomb_pages`: The total number of pages which do not contain any
|
|
371
|
+
# live slots.
|
|
372
|
+
# * `:total_allocated_pages`: The cumulative number of pages allocated since
|
|
373
|
+
# application start.
|
|
374
|
+
# * `:total_freed_pages`: The cumulative number of pages freed since
|
|
375
|
+
# application start.
|
|
376
|
+
# * `:total_allocated_objects`: The cumulative number of objects allocated
|
|
377
|
+
# since application start.
|
|
378
|
+
# * `:total_freed_objects`: The cumulative number of objects freed since
|
|
379
|
+
# application start.
|
|
380
|
+
# * `:malloc_increase_bytes`: Amount of memory allocated on the heap for
|
|
381
|
+
# objects. Decreased by any GC.
|
|
382
|
+
# * `:malloc_increase_bytes_limit`: When `:malloc_increase_bytes` crosses this
|
|
383
|
+
# limit, GC is triggered.
|
|
384
|
+
# * `:minor_gc_count`: The total number of minor garbage collections run since
|
|
385
|
+
# process start.
|
|
386
|
+
# * `:major_gc_count`: The total number of major garbage collections run since
|
|
387
|
+
# process start.
|
|
388
|
+
# * `:compact_count`: The total number of compactions run since process start.
|
|
389
|
+
# * `:read_barrier_faults`: The total number of times the read barrier was
|
|
390
|
+
# triggered during compaction.
|
|
391
|
+
# * `:total_moved_objects`: The total number of objects compaction has moved.
|
|
392
|
+
# * `:remembered_wb_unprotected_objects`: The total number of objects without
|
|
393
|
+
# write barriers.
|
|
394
|
+
# * `:remembered_wb_unprotected_objects_limit`: When
|
|
395
|
+
# `:remembered_wb_unprotected_objects` crosses this limit, major GC is
|
|
396
|
+
# triggered.
|
|
397
|
+
# * `:old_objects`: Number of live, old objects which have survived at least 3
|
|
398
|
+
# garbage collections.
|
|
399
|
+
# * `:old_objects_limit`: When `:old_objects` crosses this limit, major GC is
|
|
400
|
+
# triggered.
|
|
401
|
+
# * `:oldmalloc_increase_bytes`: Amount of memory allocated on the heap for
|
|
402
|
+
# objects. Decreased by major GC.
|
|
403
|
+
# * `:oldmalloc_increase_bytes_limit`: When `:oldmalloc_increase_bytes`
|
|
404
|
+
# crosses this limit, major GC is triggered.
|
|
406
405
|
#
|
|
407
406
|
def self.stat: (?Hash[Symbol, untyped]? hash) -> Hash[Symbol, untyped]
|
|
408
407
|
| (Symbol key) -> Integer
|
|
409
408
|
|
|
410
409
|
# <!--
|
|
411
410
|
# rdoc-file=gc.rb
|
|
412
|
-
# - GC.measure_total_time =
|
|
411
|
+
# - GC.measure_total_time = setting -> setting
|
|
413
412
|
# -->
|
|
414
|
-
# Enables
|
|
415
|
-
#
|
|
413
|
+
# Enables or disables GC total time measurement; returns `setting`. See
|
|
414
|
+
# GC.total_time.
|
|
415
|
+
#
|
|
416
|
+
# When argument `object` is `nil` or `false`, disables total time measurement;
|
|
417
|
+
# GC.measure_total_time then returns `false`:
|
|
418
|
+
#
|
|
419
|
+
# GC.measure_total_time = nil # => nil
|
|
420
|
+
# GC.measure_total_time # => false
|
|
421
|
+
# GC.measure_total_time = false # => false
|
|
422
|
+
# GC.measure_total_time # => false
|
|
423
|
+
#
|
|
424
|
+
# Otherwise, enables total time measurement; GC.measure_total_time then returns
|
|
425
|
+
# `true`:
|
|
426
|
+
#
|
|
427
|
+
# GC.measure_total_time = true # => true
|
|
428
|
+
# GC.measure_total_time # => true
|
|
429
|
+
# GC.measure_total_time = :foo # => :foo
|
|
430
|
+
# GC.measure_total_time # => true
|
|
431
|
+
#
|
|
432
|
+
# Note that when enabled, total time measurement affects performance.
|
|
416
433
|
#
|
|
417
434
|
def self.measure_total_time=: [T] (T enable) -> T
|
|
418
435
|
|
|
419
436
|
# <!--
|
|
420
437
|
# rdoc-file=gc.rb
|
|
421
|
-
# - GC.measure_total_time -> true
|
|
438
|
+
# - GC.measure_total_time -> true or false
|
|
422
439
|
# -->
|
|
423
|
-
# Returns the
|
|
424
|
-
#
|
|
440
|
+
# Returns the setting for GC total time measurement; the initial setting is
|
|
441
|
+
# `true`. See GC.total_time.
|
|
425
442
|
#
|
|
426
443
|
def self.measure_total_time: () -> bool
|
|
427
444
|
|
|
@@ -447,71 +464,137 @@ module GC
|
|
|
447
464
|
|
|
448
465
|
# <!--
|
|
449
466
|
# rdoc-file=gc.rb
|
|
450
|
-
# - GC.stat_heap ->
|
|
451
|
-
# - GC.stat_heap(
|
|
452
|
-
# - GC.stat_heap(
|
|
453
|
-
# - GC.stat_heap(
|
|
454
|
-
# - GC.stat_heap(
|
|
467
|
+
# - GC.stat_heap -> new_hash
|
|
468
|
+
# - GC.stat_heap(heap_id) -> new_hash
|
|
469
|
+
# - GC.stat_heap(heap_id, key) -> value
|
|
470
|
+
# - GC.stat_heap(nil, hash) -> hash
|
|
471
|
+
# - GC.stat_heap(heap_id, hash) -> hash
|
|
455
472
|
# -->
|
|
456
|
-
#
|
|
457
|
-
#
|
|
458
|
-
#
|
|
459
|
-
#
|
|
460
|
-
#
|
|
461
|
-
#
|
|
462
|
-
#
|
|
463
|
-
#
|
|
464
|
-
#
|
|
465
|
-
#
|
|
466
|
-
#
|
|
467
|
-
#
|
|
468
|
-
#
|
|
469
|
-
#
|
|
470
|
-
#
|
|
471
|
-
#
|
|
472
|
-
#
|
|
473
|
-
#
|
|
474
|
-
#
|
|
475
|
-
#
|
|
476
|
-
#
|
|
477
|
-
#
|
|
478
|
-
#
|
|
479
|
-
#
|
|
480
|
-
#
|
|
481
|
-
#
|
|
482
|
-
#
|
|
483
|
-
#
|
|
484
|
-
#
|
|
485
|
-
#
|
|
486
|
-
#
|
|
487
|
-
#
|
|
488
|
-
#
|
|
489
|
-
#
|
|
490
|
-
#
|
|
491
|
-
#
|
|
492
|
-
#
|
|
493
|
-
#
|
|
494
|
-
#
|
|
495
|
-
#
|
|
496
|
-
#
|
|
497
|
-
#
|
|
498
|
-
#
|
|
499
|
-
#
|
|
500
|
-
#
|
|
501
|
-
#
|
|
502
|
-
#
|
|
503
|
-
#
|
|
504
|
-
#
|
|
505
|
-
#
|
|
506
|
-
#
|
|
507
|
-
#
|
|
508
|
-
#
|
|
509
|
-
#
|
|
510
|
-
#
|
|
511
|
-
#
|
|
512
|
-
#
|
|
513
|
-
#
|
|
514
|
-
#
|
|
473
|
+
# This method is implementation-specific to CRuby.
|
|
474
|
+
#
|
|
475
|
+
# Returns statistics for GC heaps. The particular statistics are
|
|
476
|
+
# implementation-specific and may change in the future without notice.
|
|
477
|
+
#
|
|
478
|
+
# With no argument given, returns statistics for all heaps:
|
|
479
|
+
#
|
|
480
|
+
# GC.stat_heap
|
|
481
|
+
# # =>
|
|
482
|
+
# {0 =>
|
|
483
|
+
# {slot_size: 40,
|
|
484
|
+
# heap_eden_pages: 246,
|
|
485
|
+
# heap_eden_slots: 402802,
|
|
486
|
+
# total_allocated_pages: 246,
|
|
487
|
+
# force_major_gc_count: 2,
|
|
488
|
+
# force_incremental_marking_finish_count: 1,
|
|
489
|
+
# total_allocated_objects: 33867152,
|
|
490
|
+
# total_freed_objects: 33520523},
|
|
491
|
+
# 1 =>
|
|
492
|
+
# {slot_size: 80,
|
|
493
|
+
# heap_eden_pages: 84,
|
|
494
|
+
# heap_eden_slots: 68746,
|
|
495
|
+
# total_allocated_pages: 84,
|
|
496
|
+
# force_major_gc_count: 1,
|
|
497
|
+
# force_incremental_marking_finish_count: 4,
|
|
498
|
+
# total_allocated_objects: 147491,
|
|
499
|
+
# total_freed_objects: 90699},
|
|
500
|
+
# 2 =>
|
|
501
|
+
# {slot_size: 160,
|
|
502
|
+
# heap_eden_pages: 157,
|
|
503
|
+
# heap_eden_slots: 64182,
|
|
504
|
+
# total_allocated_pages: 157,
|
|
505
|
+
# force_major_gc_count: 0,
|
|
506
|
+
# force_incremental_marking_finish_count: 0,
|
|
507
|
+
# total_allocated_objects: 211460,
|
|
508
|
+
# total_freed_objects: 190075},
|
|
509
|
+
# 3 =>
|
|
510
|
+
# {slot_size: 320,
|
|
511
|
+
# heap_eden_pages: 8,
|
|
512
|
+
# heap_eden_slots: 1631,
|
|
513
|
+
# total_allocated_pages: 8,
|
|
514
|
+
# force_major_gc_count: 0,
|
|
515
|
+
# force_incremental_marking_finish_count: 0,
|
|
516
|
+
# total_allocated_objects: 1422,
|
|
517
|
+
# total_freed_objects: 700},
|
|
518
|
+
# 4 =>
|
|
519
|
+
# {slot_size: 640,
|
|
520
|
+
# heap_eden_pages: 16,
|
|
521
|
+
# heap_eden_slots: 1628,
|
|
522
|
+
# total_allocated_pages: 16,
|
|
523
|
+
# force_major_gc_count: 0,
|
|
524
|
+
# force_incremental_marking_finish_count: 0,
|
|
525
|
+
# total_allocated_objects: 1230,
|
|
526
|
+
# total_freed_objects: 309}}
|
|
527
|
+
#
|
|
528
|
+
# In the example above, the keys in the outer hash are the heap identifiers:
|
|
529
|
+
#
|
|
530
|
+
# GC.stat_heap.keys # => [0, 1, 2, 3, 4]
|
|
531
|
+
#
|
|
532
|
+
# On CRuby, each heap identifier is an integer; on other implementations, a heap
|
|
533
|
+
# identifier may be a string.
|
|
534
|
+
#
|
|
535
|
+
# With only argument `heap_id` given, returns statistics for the given heap
|
|
536
|
+
# identifier:
|
|
537
|
+
#
|
|
538
|
+
# GC.stat_heap(2)
|
|
539
|
+
# # =>
|
|
540
|
+
# {slot_size: 160,
|
|
541
|
+
# heap_eden_pages: 157,
|
|
542
|
+
# heap_eden_slots: 64182,
|
|
543
|
+
# total_allocated_pages: 157,
|
|
544
|
+
# force_major_gc_count: 0,
|
|
545
|
+
# force_incremental_marking_finish_count: 0,
|
|
546
|
+
# total_allocated_objects: 225018,
|
|
547
|
+
# total_freed_objects: 206647}
|
|
548
|
+
#
|
|
549
|
+
# With arguments `heap_id` and `key` given, returns the value for the given key
|
|
550
|
+
# in the given heap:
|
|
551
|
+
#
|
|
552
|
+
# GC.stat_heap(2, :slot_size) # => 160
|
|
553
|
+
#
|
|
554
|
+
# With arguments `nil` and `hash` given, merges the statistics for all heaps
|
|
555
|
+
# into the given hash:
|
|
556
|
+
#
|
|
557
|
+
# h = {foo: 0, bar: 1}
|
|
558
|
+
# GC.stat_heap(nil, h).keys # => [:foo, :bar, 0, 1, 2, 3, 4]
|
|
559
|
+
#
|
|
560
|
+
# With arguments `heap_id` and `hash` given, merges the statistics for the given
|
|
561
|
+
# heap into the given hash:
|
|
562
|
+
#
|
|
563
|
+
# h = {foo: 0, bar: 1}
|
|
564
|
+
# GC.stat_heap(2, h).keys
|
|
565
|
+
# # =>
|
|
566
|
+
# [:foo,
|
|
567
|
+
# :bar,
|
|
568
|
+
# :slot_size,
|
|
569
|
+
# :heap_eden_pages,
|
|
570
|
+
# :heap_eden_slots,
|
|
571
|
+
# :total_allocated_pages,
|
|
572
|
+
# :force_major_gc_count,
|
|
573
|
+
# :force_incremental_marking_finish_count,
|
|
574
|
+
# :total_allocated_objects,
|
|
575
|
+
# :total_freed_objects]
|
|
576
|
+
#
|
|
577
|
+
# The statistics for a heap may include:
|
|
578
|
+
#
|
|
579
|
+
# * `:slot_size`: The slot size of the heap in bytes.
|
|
580
|
+
# * `:heap_allocatable_pages`: The number of pages that can be allocated
|
|
581
|
+
# without triggering a new garbage collection cycle.
|
|
582
|
+
# * `:heap_eden_pages`: The number of pages in the eden heap.
|
|
583
|
+
# * `:heap_eden_slots`: The total number of slots in all of the pages in the
|
|
584
|
+
# eden heap.
|
|
585
|
+
# * `:heap_tomb_pages`: The number of pages in the tomb heap. The tomb heap
|
|
586
|
+
# only contains pages that do not have any live objects.
|
|
587
|
+
# * `:heap_tomb_slots`: The total number of slots in all of the pages in the
|
|
588
|
+
# tomb heap.
|
|
589
|
+
# * `:total_allocated_pages`: The total number of pages that have been
|
|
590
|
+
# allocated in the heap.
|
|
591
|
+
# * `:total_freed_pages`: The total number of pages that have been freed and
|
|
592
|
+
# released back to the system in the heap.
|
|
593
|
+
# * `:force_major_gc_count`: The number of times this heap has forced major
|
|
594
|
+
# garbage collection cycles to start due to running out of free slots.
|
|
595
|
+
# * `:force_incremental_marking_finish_count`: The number of times this heap
|
|
596
|
+
# has forced incremental marking to complete due to running out of pooled
|
|
597
|
+
# slots.
|
|
515
598
|
#
|
|
516
599
|
def self.stat_heap: (?Integer? heap_name, ?Hash[Symbol, untyped]? hash) -> Hash[Symbol, untyped]
|
|
517
600
|
| (Integer heap_name, Symbol key) -> Integer
|
|
@@ -532,37 +615,67 @@ module GC
|
|
|
532
615
|
|
|
533
616
|
# <!--
|
|
534
617
|
# rdoc-file=gc.rb
|
|
535
|
-
# - GC.stress ->
|
|
618
|
+
# - GC.stress -> setting
|
|
536
619
|
# -->
|
|
537
|
-
# Returns the current
|
|
620
|
+
# Returns the current GC stress-mode setting, which initially is `false`.
|
|
621
|
+
#
|
|
622
|
+
# The stress mode may be set by method GC.stress=.
|
|
538
623
|
#
|
|
539
624
|
def self.stress: () -> (Integer | bool)
|
|
540
625
|
|
|
541
626
|
# <!--
|
|
542
627
|
# rdoc-file=gc.rb
|
|
543
|
-
# - GC.stress =
|
|
628
|
+
# - GC.stress = value -> value
|
|
544
629
|
# -->
|
|
545
|
-
#
|
|
630
|
+
# Enables or disables stress mode; enabling stress mode will degrade
|
|
631
|
+
# performance; it is only for debugging.
|
|
632
|
+
#
|
|
633
|
+
# Sets the current GC stress mode to the given value:
|
|
546
634
|
#
|
|
547
|
-
#
|
|
548
|
-
#
|
|
635
|
+
# * If the value is `nil` or `false`, disables stress mode.
|
|
636
|
+
# * If the value is an integer, enables stress mode with certain flags; see
|
|
637
|
+
# below.
|
|
638
|
+
# * Otherwise, enables stress mode; GC is invoked at every GC opportunity: all
|
|
639
|
+
# memory and object allocations.
|
|
549
640
|
#
|
|
550
|
-
#
|
|
641
|
+
# The flags are bits in the given integer:
|
|
551
642
|
#
|
|
552
|
-
#
|
|
553
|
-
#
|
|
554
|
-
#
|
|
555
|
-
# 0x02:: no immediate sweep
|
|
556
|
-
# 0x04:: full mark after malloc/calloc/realloc
|
|
643
|
+
# * `0x01`: No major GC.
|
|
644
|
+
# * `0x02`: No immediate sweep.
|
|
645
|
+
# * `0x04`: Full mark after malloc/calloc/realloc.
|
|
557
646
|
#
|
|
558
647
|
def self.stress=: (Integer flag) -> Integer
|
|
559
648
|
| (bool flag) -> bool
|
|
560
649
|
|
|
561
650
|
# <!--
|
|
562
651
|
# rdoc-file=gc.rb
|
|
563
|
-
# - GC.total_time ->
|
|
652
|
+
# - GC.total_time -> integer
|
|
564
653
|
# -->
|
|
565
|
-
# Returns the
|
|
654
|
+
# Returns the GC total time in nanoseconds:
|
|
655
|
+
#
|
|
656
|
+
# GC.total_time # => 156250
|
|
657
|
+
#
|
|
658
|
+
# Note that total time accumulates only when total time measurement is enabled
|
|
659
|
+
# (that is, when GC.measure_total_time is `true`):
|
|
660
|
+
#
|
|
661
|
+
# GC.measure_total_time # => true
|
|
662
|
+
# GC.total_time # => 625000
|
|
663
|
+
# GC.start
|
|
664
|
+
# GC.total_time # => 937500
|
|
665
|
+
# GC.start
|
|
666
|
+
# GC.total_time # => 1093750
|
|
667
|
+
#
|
|
668
|
+
# GC.measure_total_time = false
|
|
669
|
+
# GC.total_time # => 1250000
|
|
670
|
+
# GC.start
|
|
671
|
+
# GC.total_time # => 1250000
|
|
672
|
+
# GC.start
|
|
673
|
+
# GC.total_time # => 1250000
|
|
674
|
+
#
|
|
675
|
+
# GC.measure_total_time = true
|
|
676
|
+
# GC.total_time # => 1250000
|
|
677
|
+
# GC.start
|
|
678
|
+
# GC.total_time # => 1406250
|
|
566
679
|
#
|
|
567
680
|
def self.total_time: () -> Integer
|
|
568
681
|
|
|
@@ -619,17 +732,45 @@ module GC
|
|
|
619
732
|
|
|
620
733
|
# <!--
|
|
621
734
|
# rdoc-file=gc.rb
|
|
622
|
-
# - GC.latest_gc_info ->
|
|
623
|
-
# - GC.latest_gc_info(hash) -> hash
|
|
735
|
+
# - GC.latest_gc_info -> new_hash
|
|
624
736
|
# - GC.latest_gc_info(key) -> value
|
|
737
|
+
# - GC.latest_gc_info(hash) -> hash
|
|
625
738
|
# -->
|
|
626
|
-
#
|
|
627
|
-
#
|
|
628
|
-
#
|
|
629
|
-
#
|
|
630
|
-
#
|
|
631
|
-
#
|
|
632
|
-
#
|
|
739
|
+
# With no argument given, returns information about the most recent garbage
|
|
740
|
+
# collection:
|
|
741
|
+
#
|
|
742
|
+
# GC.latest_gc_info
|
|
743
|
+
# # =>
|
|
744
|
+
# {major_by: :force,
|
|
745
|
+
# need_major_by: nil,
|
|
746
|
+
# gc_by: :method,
|
|
747
|
+
# have_finalizer: false,
|
|
748
|
+
# immediate_sweep: true,
|
|
749
|
+
# state: :none,
|
|
750
|
+
# weak_references_count: 0,
|
|
751
|
+
# retained_weak_references_count: 0}
|
|
752
|
+
#
|
|
753
|
+
# With symbol argument `key` given, returns the value for that key:
|
|
754
|
+
#
|
|
755
|
+
# GC.latest_gc_info(:gc_by) # => :newobj
|
|
756
|
+
#
|
|
757
|
+
# With hash argument `hash` given, returns that hash with GC information merged
|
|
758
|
+
# into its content; this form may be useful in minimizing [probe
|
|
759
|
+
# effects](https://en.wikipedia.org/wiki/Probe_effect):
|
|
760
|
+
#
|
|
761
|
+
# h = {foo: 0, bar: 1}
|
|
762
|
+
# GC.latest_gc_info(h)
|
|
763
|
+
# # =>
|
|
764
|
+
# {foo: 0,
|
|
765
|
+
# bar: 1,
|
|
766
|
+
# major_by: nil,
|
|
767
|
+
# need_major_by: nil,
|
|
768
|
+
# gc_by: :newobj,
|
|
769
|
+
# have_finalizer: false,
|
|
770
|
+
# immediate_sweep: false,
|
|
771
|
+
# state: :sweeping,
|
|
772
|
+
# weak_references_count: 0,
|
|
773
|
+
# retained_weak_references_count: 0}
|
|
633
774
|
#
|
|
634
775
|
def self.latest_gc_info: (?Hash[Symbol, untyped]? hash) -> Hash[Symbol, untyped]
|
|
635
776
|
| (Symbol key) -> untyped
|