rbs 3.10.0 → 4.0.0.dev.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/.github/workflows/comments.yml +3 -3
- data/.github/workflows/ruby.yml +24 -35
- data/.github/workflows/typecheck.yml +3 -1
- data/.github/workflows/windows.yml +2 -2
- data/.gitignore +0 -4
- data/CHANGELOG.md +0 -88
- data/README.md +1 -38
- data/Rakefile +20 -142
- data/Steepfile +1 -0
- data/config.yml +43 -1
- data/core/array.rbs +46 -100
- data/core/complex.rbs +21 -32
- data/core/dir.rbs +2 -2
- data/core/encoding.rbs +9 -6
- data/core/enumerable.rbs +3 -90
- data/core/enumerator.rbs +1 -18
- data/core/errno.rbs +0 -8
- data/core/errors.rbs +1 -28
- data/core/exception.rbs +2 -2
- data/core/fiber.rbs +4 -5
- data/core/file.rbs +12 -27
- data/core/file_test.rbs +1 -1
- data/core/float.rbs +22 -209
- data/core/gc.rbs +281 -417
- data/core/hash.rbs +727 -1024
- data/core/integer.rbs +38 -78
- data/core/io/buffer.rbs +7 -18
- data/core/io/wait.rbs +33 -11
- data/core/io.rbs +12 -14
- data/core/kernel.rbs +51 -57
- data/core/marshal.rbs +1 -1
- data/core/match_data.rbs +1 -1
- data/core/math.rbs +3 -42
- data/core/method.rbs +6 -14
- data/core/module.rbs +17 -88
- data/core/nil_class.rbs +3 -3
- data/core/numeric.rbs +16 -16
- data/core/object.rbs +3 -3
- data/core/object_space.rbs +15 -21
- data/core/proc.rbs +8 -15
- data/core/process.rbs +2 -2
- data/core/ractor.rbs +437 -278
- data/core/range.rbs +8 -7
- data/core/rational.rbs +24 -37
- data/core/rbs/unnamed/argf.rbs +2 -2
- data/core/rbs/unnamed/env_class.rbs +1 -1
- data/core/rbs/unnamed/random.rbs +2 -4
- data/core/regexp.rbs +20 -25
- data/core/ruby_vm.rbs +4 -6
- data/core/rubygems/errors.rbs +70 -3
- data/core/rubygems/rubygems.rbs +79 -11
- data/core/rubygems/version.rbs +3 -2
- data/core/set.rbs +359 -488
- data/core/string.rbs +1228 -3153
- data/core/struct.rbs +1 -1
- data/core/symbol.rbs +4 -4
- data/core/thread.rbs +29 -92
- data/core/time.rbs +9 -35
- data/core/trace_point.rbs +4 -7
- data/core/unbound_method.rbs +6 -14
- data/docs/collection.md +2 -2
- data/docs/gem.md +1 -0
- data/docs/sigs.md +3 -3
- data/ext/rbs_extension/ast_translation.c +1077 -944
- data/ext/rbs_extension/ast_translation.h +0 -7
- data/ext/rbs_extension/class_constants.c +83 -71
- data/ext/rbs_extension/class_constants.h +7 -4
- data/ext/rbs_extension/extconf.rb +2 -24
- data/ext/rbs_extension/legacy_location.c +172 -173
- data/ext/rbs_extension/legacy_location.h +3 -8
- data/ext/rbs_extension/main.c +289 -239
- data/ext/rbs_extension/rbs_extension.h +0 -3
- data/ext/rbs_extension/rbs_string_bridging.h +0 -4
- data/include/rbs/ast.h +98 -37
- data/include/rbs/defines.h +12 -38
- data/include/rbs/lexer.h +114 -126
- data/include/rbs/location.h +14 -14
- data/include/rbs/parser.h +37 -21
- data/include/rbs/string.h +5 -3
- data/include/rbs/util/rbs_allocator.h +19 -40
- data/include/rbs/util/rbs_assert.h +1 -12
- data/include/rbs/util/rbs_constant_pool.h +3 -3
- data/include/rbs/util/rbs_encoding.h +1 -3
- data/include/rbs/util/rbs_unescape.h +1 -2
- data/lib/rbs/ast/ruby/annotations.rb +119 -0
- data/lib/rbs/ast/ruby/comment_block.rb +221 -0
- data/lib/rbs/ast/ruby/declarations.rb +86 -0
- data/lib/rbs/ast/ruby/helpers/constant_helper.rb +24 -0
- data/lib/rbs/ast/ruby/helpers/location_helper.rb +15 -0
- data/lib/rbs/ast/ruby/members.rb +213 -0
- data/lib/rbs/buffer.rb +104 -24
- data/lib/rbs/cli/validate.rb +40 -35
- data/lib/rbs/cli.rb +5 -6
- data/lib/rbs/collection/config/lockfile_generator.rb +0 -1
- data/lib/rbs/collection.rb +0 -1
- data/lib/rbs/definition.rb +6 -1
- data/lib/rbs/definition_builder/ancestor_builder.rb +65 -62
- data/lib/rbs/definition_builder/method_builder.rb +45 -30
- data/lib/rbs/definition_builder.rb +44 -9
- data/lib/rbs/environment/class_entry.rb +69 -0
- data/lib/rbs/environment/module_entry.rb +66 -0
- data/lib/rbs/environment.rb +244 -218
- data/lib/rbs/environment_loader.rb +3 -3
- data/lib/rbs/errors.rb +5 -4
- data/lib/rbs/inline_parser/comment_association.rb +117 -0
- data/lib/rbs/inline_parser.rb +206 -0
- data/lib/rbs/location_aux.rb +35 -3
- data/lib/rbs/parser_aux.rb +11 -6
- data/lib/rbs/prototype/runtime.rb +2 -2
- data/lib/rbs/resolver/constant_resolver.rb +2 -2
- data/lib/rbs/resolver/type_name_resolver.rb +38 -124
- data/lib/rbs/source.rb +99 -0
- data/lib/rbs/subtractor.rb +4 -3
- data/lib/rbs/test/type_check.rb +0 -14
- data/lib/rbs/types.rb +1 -3
- data/lib/rbs/version.rb +1 -1
- data/lib/rbs.rb +13 -1
- data/lib/rdoc/discover.rb +1 -1
- data/lib/rdoc_plugin/parser.rb +1 -1
- data/rbs.gemspec +1 -0
- data/sig/ancestor_builder.rbs +1 -1
- data/sig/ast/ruby/annotations.rbs +110 -0
- data/sig/ast/ruby/comment_block.rbs +119 -0
- data/sig/ast/ruby/declarations.rbs +60 -0
- data/sig/ast/ruby/helpers/constant_helper.rbs +11 -0
- data/sig/ast/ruby/helpers/location_helper.rbs +15 -0
- data/sig/ast/ruby/members.rbs +72 -0
- data/sig/buffer.rbs +63 -5
- data/sig/definition.rbs +1 -0
- data/sig/definition_builder.rbs +1 -1
- data/sig/environment/class_entry.rbs +50 -0
- data/sig/environment/module_entry.rbs +50 -0
- data/sig/environment.rbs +28 -133
- data/sig/errors.rbs +13 -6
- data/sig/inline_parser/comment_association.rbs +71 -0
- data/sig/inline_parser.rbs +87 -0
- data/sig/location.rbs +32 -7
- data/sig/manifest.yaml +1 -0
- data/sig/method_builder.rbs +7 -4
- data/sig/parser.rbs +16 -20
- data/sig/resolver/type_name_resolver.rbs +7 -38
- data/sig/source.rbs +48 -0
- data/sig/types.rbs +1 -4
- data/src/ast.c +290 -201
- data/src/lexer.c +2813 -2902
- data/src/lexer.re +4 -0
- data/src/lexstate.c +155 -169
- data/src/location.c +40 -40
- data/src/parser.c +2665 -2433
- data/src/string.c +48 -0
- data/src/util/rbs_allocator.c +77 -80
- data/src/util/rbs_assert.c +10 -10
- data/src/util/rbs_buffer.c +2 -2
- data/src/util/rbs_constant_pool.c +15 -13
- data/src/util/rbs_encoding.c +4062 -20097
- data/src/util/rbs_unescape.c +48 -85
- data/stdlib/bigdecimal/0/big_decimal.rbs +82 -100
- data/stdlib/bigdecimal-math/0/big_math.rbs +8 -169
- data/stdlib/cgi/0/core.rbs +396 -2
- data/stdlib/cgi/0/manifest.yaml +0 -1
- data/stdlib/coverage/0/coverage.rbs +1 -3
- data/stdlib/date/0/date.rbs +59 -67
- data/stdlib/date/0/date_time.rbs +1 -1
- data/stdlib/delegate/0/delegator.rbs +7 -10
- data/stdlib/erb/0/erb.rbs +347 -737
- data/stdlib/fileutils/0/fileutils.rbs +13 -18
- data/stdlib/forwardable/0/forwardable.rbs +0 -3
- data/stdlib/json/0/json.rbs +48 -68
- data/stdlib/net-http/0/net-http.rbs +0 -3
- data/stdlib/objspace/0/objspace.rbs +4 -9
- data/stdlib/open-uri/0/open-uri.rbs +0 -40
- data/stdlib/openssl/0/openssl.rbs +228 -331
- data/stdlib/optparse/0/optparse.rbs +3 -3
- data/{core → stdlib/pathname/0}/pathname.rbs +355 -255
- data/stdlib/psych/0/psych.rbs +3 -3
- data/stdlib/rdoc/0/rdoc.rbs +1 -1
- data/stdlib/resolv/0/resolv.rbs +68 -25
- data/stdlib/ripper/0/ripper.rbs +2 -5
- data/stdlib/singleton/0/singleton.rbs +0 -3
- data/stdlib/socket/0/socket.rbs +1 -13
- data/stdlib/socket/0/tcp_socket.rbs +2 -10
- data/stdlib/stringio/0/stringio.rbs +85 -1176
- data/stdlib/strscan/0/string_scanner.rbs +31 -31
- data/stdlib/tempfile/0/tempfile.rbs +3 -3
- data/stdlib/time/0/time.rbs +1 -1
- data/stdlib/timeout/0/timeout.rbs +7 -63
- data/stdlib/tsort/0/cyclic.rbs +0 -3
- data/stdlib/uri/0/common.rbs +2 -11
- data/stdlib/uri/0/file.rbs +1 -1
- data/stdlib/uri/0/generic.rbs +16 -17
- data/stdlib/uri/0/rfc2396_parser.rbs +7 -6
- data/stdlib/zlib/0/zstream.rbs +0 -1
- metadata +40 -12
- data/.clang-format +0 -74
- data/.clangd +0 -2
- data/.github/workflows/c-check.yml +0 -54
- data/core/ruby.rbs +0 -53
- data/docs/aliases.md +0 -79
- data/docs/encoding.md +0 -56
- data/ext/rbs_extension/compat.h +0 -10
- data/stdlib/cgi-escape/0/escape.rbs +0 -153
data/core/gc.rbs
CHANGED
|
@@ -160,65 +160,81 @@ module GC
|
|
|
160
160
|
# <!--
|
|
161
161
|
# rdoc-file=gc.rb
|
|
162
162
|
# - GC.config -> hash
|
|
163
|
-
# - GC.config(
|
|
163
|
+
# - GC.config(hash) -> hash
|
|
164
164
|
# -->
|
|
165
|
-
#
|
|
166
|
-
#
|
|
167
|
-
# Sets or gets information about the current GC configuration.
|
|
165
|
+
# Sets or gets information about the current GC config.
|
|
168
166
|
#
|
|
169
167
|
# Configuration parameters are GC implementation-specific and may change without
|
|
170
168
|
# notice.
|
|
171
169
|
#
|
|
172
|
-
#
|
|
170
|
+
# This method can be called without parameters to retrieve the current config as
|
|
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.
|
|
173
188
|
#
|
|
174
|
-
#
|
|
175
|
-
# # => {rgengc_allow_full_mark: true, implementation: "default"}
|
|
189
|
+
# ### GC Implementation independent values
|
|
176
190
|
#
|
|
177
|
-
#
|
|
178
|
-
#
|
|
191
|
+
# The `GC.config` hash can also contain keys that are global and read-only.
|
|
192
|
+
# These keys are not specific to any one GC library implementation and
|
|
193
|
+
# attempting to write to them will raise `ArgumentError`.
|
|
179
194
|
#
|
|
180
|
-
#
|
|
181
|
-
# # => {rgengc_allow_full_mark: false, implementation: "default"}
|
|
182
|
-
# GC.config(foo: 'bar')
|
|
183
|
-
# # => {rgengc_allow_full_mark: false, implementation: "default"}
|
|
195
|
+
# There is currently only one global, read-only key:
|
|
184
196
|
#
|
|
185
|
-
#
|
|
197
|
+
# implementation
|
|
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
|
|
186
201
|
#
|
|
187
|
-
# The single read-only entry for all implementations is:
|
|
188
202
|
#
|
|
189
|
-
#
|
|
190
|
-
# default implementation, `'default'`.
|
|
203
|
+
# ### GC Implementation specific values
|
|
191
204
|
#
|
|
192
|
-
#
|
|
205
|
+
# GC libraries are expected to document their own configuration. Valid keys for
|
|
206
|
+
# Ruby's default GC implementation are:
|
|
193
207
|
#
|
|
194
|
-
#
|
|
208
|
+
# rgengc_allow_full_mark
|
|
209
|
+
# : Controls whether the GC is allowed to run a full mark (young & old
|
|
210
|
+
# objects).
|
|
195
211
|
#
|
|
196
|
-
#
|
|
212
|
+
# When `true`, GC interleaves major and minor collections. This is the
|
|
213
|
+
# default. GC will function as intended.
|
|
197
214
|
#
|
|
198
|
-
#
|
|
199
|
-
#
|
|
215
|
+
# When `false`, the GC will never trigger a full marking cycle unless
|
|
216
|
+
# explicitly requested by user code. Instead, only a minor mark will
|
|
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.
|
|
200
219
|
#
|
|
201
|
-
#
|
|
202
|
-
#
|
|
203
|
-
#
|
|
204
|
-
#
|
|
205
|
-
#
|
|
206
|
-
#
|
|
207
|
-
#
|
|
208
|
-
#
|
|
220
|
+
# A flag will be set to notify that a full mark has been requested. This
|
|
221
|
+
# flag is accessible using `GC.latest_gc_info(:needs_major_by)`
|
|
222
|
+
#
|
|
223
|
+
# The user can trigger a major collection at any time using
|
|
224
|
+
# `GC.start(full_mark: true)`
|
|
225
|
+
#
|
|
226
|
+
# When `false`, Young to Old object promotion is disabled. For performance
|
|
227
|
+
# reasons, it is recommended to warm up an application using
|
|
228
|
+
# `Process.warmup` before setting this parameter to `false`.
|
|
209
229
|
#
|
|
210
230
|
def self.config: () -> Hash[Symbol, untyped]
|
|
211
231
|
| (Hash[Symbol, untyped]) -> Hash[Symbol, untyped]
|
|
212
232
|
|
|
213
233
|
# <!--
|
|
214
234
|
# rdoc-file=gc.rb
|
|
215
|
-
# -
|
|
235
|
+
# - GC.count -> Integer
|
|
216
236
|
# -->
|
|
217
|
-
# Returns the
|
|
218
|
-
#
|
|
219
|
-
# GC.count # => 385
|
|
220
|
-
# GC.start
|
|
221
|
-
# GC.count # => 386
|
|
237
|
+
# Returns the number of times GC has occurred since the process started.
|
|
222
238
|
#
|
|
223
239
|
def self.count: () -> Integer
|
|
224
240
|
|
|
@@ -226,12 +242,11 @@ module GC
|
|
|
226
242
|
# rdoc-file=gc.rb
|
|
227
243
|
# - GC.disable -> true or false
|
|
228
244
|
# -->
|
|
229
|
-
# Disables garbage collection
|
|
230
|
-
#
|
|
245
|
+
# Disables garbage collection, returning `true` if garbage collection was
|
|
246
|
+
# already disabled.
|
|
231
247
|
#
|
|
232
|
-
# GC.
|
|
233
|
-
# GC.disable
|
|
234
|
-
# GC.disable # => true
|
|
248
|
+
# GC.disable #=> false
|
|
249
|
+
# GC.disable #=> true
|
|
235
250
|
#
|
|
236
251
|
def self.disable: () -> bool
|
|
237
252
|
|
|
@@ -239,11 +254,12 @@ module GC
|
|
|
239
254
|
# rdoc-file=gc.rb
|
|
240
255
|
# - GC.enable -> true or false
|
|
241
256
|
# -->
|
|
242
|
-
# Enables garbage collection
|
|
257
|
+
# Enables garbage collection, returning `true` if garbage collection was
|
|
258
|
+
# previously disabled.
|
|
243
259
|
#
|
|
244
|
-
# GC.disable
|
|
245
|
-
# GC.enable
|
|
246
|
-
# GC.enable
|
|
260
|
+
# GC.disable #=> false
|
|
261
|
+
# GC.enable #=> true
|
|
262
|
+
# GC.enable #=> false
|
|
247
263
|
#
|
|
248
264
|
def self.enable: () -> bool
|
|
249
265
|
|
|
@@ -251,193 +267,161 @@ module GC
|
|
|
251
267
|
# rdoc-file=gc.rb
|
|
252
268
|
# - start(full_mark: true, immediate_mark: true, immediate_sweep: true)
|
|
253
269
|
# -->
|
|
254
|
-
# Initiates garbage collection, even if
|
|
270
|
+
# Initiates garbage collection, even if manually disabled.
|
|
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.
|
|
255
303
|
#
|
|
256
|
-
#
|
|
304
|
+
# The contents of the hash are implementation-specific and may change in the
|
|
305
|
+
# future without notice.
|
|
257
306
|
#
|
|
258
|
-
#
|
|
259
|
-
# garbage collection cycle:
|
|
307
|
+
# The hash includes internal statistics about GC such as:
|
|
260
308
|
#
|
|
261
|
-
#
|
|
262
|
-
#
|
|
263
|
-
#
|
|
264
|
-
# young objects are marked.
|
|
309
|
+
# count
|
|
310
|
+
# : The total number of garbage collections run since application start (count
|
|
311
|
+
# includes both minor and major garbage collections)
|
|
265
312
|
#
|
|
266
|
-
#
|
|
267
|
-
#
|
|
313
|
+
# time
|
|
314
|
+
# : The total time spent in garbage collections (in milliseconds)
|
|
268
315
|
#
|
|
269
|
-
#
|
|
270
|
-
#
|
|
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`.
|
|
316
|
+
# heap_allocated_pages
|
|
317
|
+
# : The total number of `:heap_eden_pages` + `:heap_tomb_pages`
|
|
275
318
|
#
|
|
276
|
-
#
|
|
277
|
-
#
|
|
319
|
+
# heap_sorted_length
|
|
320
|
+
# : The number of pages that can fit into the buffer that holds references to
|
|
321
|
+
# all pages
|
|
278
322
|
#
|
|
279
|
-
#
|
|
280
|
-
#
|
|
281
|
-
#
|
|
282
|
-
# sweeping may not be completed before the return.
|
|
323
|
+
# heap_allocatable_pages
|
|
324
|
+
# : The total number of pages the application could allocate without
|
|
325
|
+
# additional GC
|
|
283
326
|
#
|
|
284
|
-
#
|
|
285
|
-
#
|
|
286
|
-
# implementations.
|
|
327
|
+
# heap_available_slots
|
|
328
|
+
# : The total number of slots in all `:heap_allocated_pages`
|
|
287
329
|
#
|
|
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
|
-
#
|
|
324
|
-
#
|
|
325
|
-
#
|
|
326
|
-
#
|
|
327
|
-
#
|
|
328
|
-
#
|
|
329
|
-
#
|
|
330
|
-
#
|
|
331
|
-
#
|
|
332
|
-
#
|
|
333
|
-
#
|
|
334
|
-
#
|
|
335
|
-
#
|
|
336
|
-
#
|
|
337
|
-
#
|
|
338
|
-
#
|
|
339
|
-
#
|
|
340
|
-
#
|
|
341
|
-
#
|
|
342
|
-
#
|
|
343
|
-
#
|
|
344
|
-
#
|
|
345
|
-
#
|
|
346
|
-
#
|
|
347
|
-
#
|
|
348
|
-
#
|
|
349
|
-
#
|
|
350
|
-
#
|
|
351
|
-
#
|
|
352
|
-
#
|
|
353
|
-
#
|
|
354
|
-
#
|
|
355
|
-
#
|
|
356
|
-
#
|
|
357
|
-
#
|
|
358
|
-
#
|
|
359
|
-
#
|
|
360
|
-
#
|
|
361
|
-
#
|
|
362
|
-
#
|
|
363
|
-
#
|
|
364
|
-
# * `:heap_free_slots`: The total number of slots which do not contain live
|
|
365
|
-
# objects.
|
|
366
|
-
# * `:heap_final_slots`: The total number of slots with pending finalizers to
|
|
367
|
-
# be run.
|
|
368
|
-
# * `:heap_marked_slots`: The total number of objects marked in the last GC.
|
|
369
|
-
# * `:heap_eden_pages`: The total number of pages which contain at least one
|
|
370
|
-
# live slot.
|
|
371
|
-
# * `:total_allocated_pages`: The cumulative number of pages allocated since
|
|
372
|
-
# application start.
|
|
373
|
-
# * `:total_freed_pages`: The cumulative number of pages freed since
|
|
374
|
-
# application start.
|
|
375
|
-
# * `:total_allocated_objects`: The cumulative number of objects allocated
|
|
376
|
-
# since application start.
|
|
377
|
-
# * `:total_freed_objects`: The cumulative number of objects freed since
|
|
378
|
-
# application start.
|
|
379
|
-
# * `:malloc_increase_bytes`: Amount of memory allocated on the heap for
|
|
380
|
-
# objects. Decreased by any GC.
|
|
381
|
-
# * `:malloc_increase_bytes_limit`: When `:malloc_increase_bytes` crosses this
|
|
382
|
-
# limit, GC is triggered.
|
|
383
|
-
# * `:minor_gc_count`: The total number of minor garbage collections run since
|
|
384
|
-
# process start.
|
|
385
|
-
# * `:major_gc_count`: The total number of major garbage collections run since
|
|
386
|
-
# process start.
|
|
387
|
-
# * `:compact_count`: The total number of compactions run since process start.
|
|
388
|
-
# * `:read_barrier_faults`: The total number of times the read barrier was
|
|
389
|
-
# triggered during compaction.
|
|
390
|
-
# * `:total_moved_objects`: The total number of objects compaction has moved.
|
|
391
|
-
# * `:remembered_wb_unprotected_objects`: The total number of objects without
|
|
392
|
-
# write barriers.
|
|
393
|
-
# * `:remembered_wb_unprotected_objects_limit`: When
|
|
394
|
-
# `:remembered_wb_unprotected_objects` crosses this limit, major GC is
|
|
395
|
-
# triggered.
|
|
396
|
-
# * `:old_objects`: Number of live, old objects which have survived at least 3
|
|
397
|
-
# garbage collections.
|
|
398
|
-
# * `:old_objects_limit`: When `:old_objects` crosses this limit, major GC is
|
|
399
|
-
# triggered.
|
|
400
|
-
# * `:oldmalloc_increase_bytes`: Amount of memory allocated on the heap for
|
|
401
|
-
# objects. Decreased by major GC.
|
|
402
|
-
# * `:oldmalloc_increase_bytes_limit`: When `:oldmalloc_increase_bytes`
|
|
403
|
-
# crosses this limit, major GC is triggered.
|
|
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
|
|
380
|
+
#
|
|
381
|
+
# remembered_wb_unprotected_objects
|
|
382
|
+
# : The total number of objects without write barriers
|
|
383
|
+
#
|
|
384
|
+
# remembered_wb_unprotected_objects_limit
|
|
385
|
+
# : When `:remembered_wb_unprotected_objects` crosses this limit, major GC is
|
|
386
|
+
# triggered
|
|
387
|
+
#
|
|
388
|
+
# old_objects
|
|
389
|
+
# : Number of live, old objects which have survived at least 3 garbage
|
|
390
|
+
# collections
|
|
391
|
+
#
|
|
392
|
+
# old_objects_limit
|
|
393
|
+
# : When `:old_objects` crosses this limit, major GC is triggered
|
|
394
|
+
#
|
|
395
|
+
# oldmalloc_increase_bytes
|
|
396
|
+
# : Amount of memory allocated on the heap for objects. Decreased by major GC
|
|
397
|
+
#
|
|
398
|
+
# oldmalloc_increase_bytes_limit
|
|
399
|
+
# : When `:oldmalloc_increase_bytes` crosses this limit, major GC is triggered
|
|
400
|
+
#
|
|
401
|
+
#
|
|
402
|
+
# If the optional argument, hash, is given, it is overwritten and returned. This
|
|
403
|
+
# is intended to avoid the probe effect.
|
|
404
|
+
#
|
|
405
|
+
# This method is only expected to work on CRuby.
|
|
404
406
|
#
|
|
405
407
|
def self.stat: (?Hash[Symbol, untyped]? hash) -> Hash[Symbol, untyped]
|
|
406
408
|
| (Symbol key) -> Integer
|
|
407
409
|
|
|
408
410
|
# <!--
|
|
409
411
|
# rdoc-file=gc.rb
|
|
410
|
-
# - GC.measure_total_time =
|
|
412
|
+
# - GC.measure_total_time = true/false
|
|
411
413
|
# -->
|
|
412
|
-
# Enables
|
|
413
|
-
# GC.
|
|
414
|
-
#
|
|
415
|
-
# When argument `object` is `nil` or `false`, disables total time measurement;
|
|
416
|
-
# GC.measure_total_time then returns `false`:
|
|
417
|
-
#
|
|
418
|
-
# GC.measure_total_time = nil # => nil
|
|
419
|
-
# GC.measure_total_time # => false
|
|
420
|
-
# GC.measure_total_time = false # => false
|
|
421
|
-
# GC.measure_total_time # => false
|
|
422
|
-
#
|
|
423
|
-
# Otherwise, enables total time measurement; GC.measure_total_time then returns
|
|
424
|
-
# `true`:
|
|
425
|
-
#
|
|
426
|
-
# GC.measure_total_time = true # => true
|
|
427
|
-
# GC.measure_total_time # => true
|
|
428
|
-
# GC.measure_total_time = :foo # => :foo
|
|
429
|
-
# GC.measure_total_time # => true
|
|
430
|
-
#
|
|
431
|
-
# Note that when enabled, total time measurement affects performance.
|
|
414
|
+
# Enables measuring GC time. You can get the result with `GC.stat(:time)`. Note
|
|
415
|
+
# that GC time measurement can cause some performance overhead.
|
|
432
416
|
#
|
|
433
417
|
def self.measure_total_time=: [T] (T enable) -> T
|
|
434
418
|
|
|
435
419
|
# <!--
|
|
436
420
|
# rdoc-file=gc.rb
|
|
437
|
-
# - GC.measure_total_time -> true
|
|
421
|
+
# - GC.measure_total_time -> true/false
|
|
438
422
|
# -->
|
|
439
|
-
# Returns the
|
|
440
|
-
#
|
|
423
|
+
# Returns the measure_total_time flag (default: `true`). Note that measurement
|
|
424
|
+
# can affect the application's performance.
|
|
441
425
|
#
|
|
442
426
|
def self.measure_total_time: () -> bool
|
|
443
427
|
|
|
@@ -463,133 +447,71 @@ module GC
|
|
|
463
447
|
|
|
464
448
|
# <!--
|
|
465
449
|
# rdoc-file=gc.rb
|
|
466
|
-
# - GC.stat_heap ->
|
|
467
|
-
# - GC.stat_heap(
|
|
468
|
-
# - GC.stat_heap(
|
|
469
|
-
# - GC.stat_heap(
|
|
470
|
-
# - GC.stat_heap(
|
|
450
|
+
# - GC.stat_heap -> Hash
|
|
451
|
+
# - GC.stat_heap(nil, hash) -> Hash
|
|
452
|
+
# - GC.stat_heap(heap_name) -> Hash
|
|
453
|
+
# - GC.stat_heap(heap_name, hash) -> Hash
|
|
454
|
+
# - GC.stat_heap(heap_name, :key) -> Numeric
|
|
471
455
|
# -->
|
|
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
|
-
#
|
|
515
|
-
#
|
|
516
|
-
#
|
|
517
|
-
#
|
|
518
|
-
#
|
|
519
|
-
#
|
|
520
|
-
#
|
|
521
|
-
#
|
|
522
|
-
#
|
|
523
|
-
#
|
|
524
|
-
#
|
|
525
|
-
#
|
|
526
|
-
#
|
|
527
|
-
#
|
|
528
|
-
#
|
|
529
|
-
#
|
|
530
|
-
#
|
|
531
|
-
# On CRuby, each heap identifier is an integer; on other implementations, a heap
|
|
532
|
-
# identifier may be a string.
|
|
533
|
-
#
|
|
534
|
-
# With only argument `heap_id` given, returns statistics for the given heap
|
|
535
|
-
# identifier:
|
|
536
|
-
#
|
|
537
|
-
# GC.stat_heap(2)
|
|
538
|
-
# # =>
|
|
539
|
-
# {slot_size: 160,
|
|
540
|
-
# heap_eden_pages: 157,
|
|
541
|
-
# heap_eden_slots: 64182,
|
|
542
|
-
# total_allocated_pages: 157,
|
|
543
|
-
# force_major_gc_count: 0,
|
|
544
|
-
# force_incremental_marking_finish_count: 0,
|
|
545
|
-
# total_allocated_objects: 225018,
|
|
546
|
-
# total_freed_objects: 206647}
|
|
547
|
-
#
|
|
548
|
-
# With arguments `heap_id` and `key` given, returns the value for the given key
|
|
549
|
-
# in the given heap:
|
|
550
|
-
#
|
|
551
|
-
# GC.stat_heap(2, :slot_size) # => 160
|
|
552
|
-
#
|
|
553
|
-
# With arguments `nil` and `hash` given, merges the statistics for all heaps
|
|
554
|
-
# into the given hash:
|
|
555
|
-
#
|
|
556
|
-
# h = {foo: 0, bar: 1}
|
|
557
|
-
# GC.stat_heap(nil, h).keys # => [:foo, :bar, 0, 1, 2, 3, 4]
|
|
558
|
-
#
|
|
559
|
-
# With arguments `heap_id` and `hash` given, merges the statistics for the given
|
|
560
|
-
# heap into the given hash:
|
|
561
|
-
#
|
|
562
|
-
# h = {foo: 0, bar: 1}
|
|
563
|
-
# GC.stat_heap(2, h).keys
|
|
564
|
-
# # =>
|
|
565
|
-
# [:foo,
|
|
566
|
-
# :bar,
|
|
567
|
-
# :slot_size,
|
|
568
|
-
# :heap_eden_pages,
|
|
569
|
-
# :heap_eden_slots,
|
|
570
|
-
# :total_allocated_pages,
|
|
571
|
-
# :force_major_gc_count,
|
|
572
|
-
# :force_incremental_marking_finish_count,
|
|
573
|
-
# :total_allocated_objects,
|
|
574
|
-
# :total_freed_objects]
|
|
575
|
-
#
|
|
576
|
-
# The statistics for a heap may include:
|
|
577
|
-
#
|
|
578
|
-
# * `:slot_size`: The slot size of the heap in bytes.
|
|
579
|
-
# * `:heap_allocatable_pages`: The number of pages that can be allocated
|
|
580
|
-
# without triggering a new garbage collection cycle.
|
|
581
|
-
# * `:heap_eden_pages`: The number of pages in the eden heap.
|
|
582
|
-
# * `:heap_eden_slots`: The total number of slots in all of the pages in the
|
|
583
|
-
# eden heap.
|
|
584
|
-
# * `:total_allocated_pages`: The total number of pages that have been
|
|
585
|
-
# allocated in the heap.
|
|
586
|
-
# * `:total_freed_pages`: The total number of pages that have been freed and
|
|
587
|
-
# released back to the system in the heap.
|
|
588
|
-
# * `:force_major_gc_count`: The number of times this heap has forced major
|
|
589
|
-
# garbage collection cycles to start due to running out of free slots.
|
|
590
|
-
# * `:force_incremental_marking_finish_count`: The number of times this heap
|
|
591
|
-
# has forced incremental marking to complete due to running out of pooled
|
|
592
|
-
# slots.
|
|
456
|
+
# Returns information for heaps in the GC.
|
|
457
|
+
#
|
|
458
|
+
# If the first optional argument, `heap_name`, is passed in and not `nil`, it
|
|
459
|
+
# returns a `Hash` containing information about the particular heap. Otherwise,
|
|
460
|
+
# it will return a `Hash` with heap names as keys and a `Hash` containing
|
|
461
|
+
# information about the heap as values.
|
|
462
|
+
#
|
|
463
|
+
# If the second optional argument, `hash_or_key`, is given as a `Hash`, it will
|
|
464
|
+
# be overwritten and returned. This is intended to avoid the probe effect.
|
|
465
|
+
#
|
|
466
|
+
# If both optional arguments are passed in and the second optional argument is a
|
|
467
|
+
# symbol, it will return a `Numeric` value for the particular heap.
|
|
468
|
+
#
|
|
469
|
+
# On CRuby, `heap_name` is of the type `Integer` but may be of type `String` on
|
|
470
|
+
# other implementations.
|
|
471
|
+
#
|
|
472
|
+
# The contents of the hash are implementation-specific and may change in the
|
|
473
|
+
# future without notice.
|
|
474
|
+
#
|
|
475
|
+
# If the optional argument, hash, is given, it is overwritten and returned.
|
|
476
|
+
#
|
|
477
|
+
# This method is only expected to work on CRuby.
|
|
478
|
+
#
|
|
479
|
+
# The hash includes the following keys about the internal information in the GC:
|
|
480
|
+
#
|
|
481
|
+
# slot_size
|
|
482
|
+
# : The slot size of the heap in bytes.
|
|
483
|
+
#
|
|
484
|
+
# heap_allocatable_pages
|
|
485
|
+
# : The number of pages that can be allocated without triggering a new garbage
|
|
486
|
+
# collection cycle.
|
|
487
|
+
#
|
|
488
|
+
# heap_eden_pages
|
|
489
|
+
# : The number of pages in the eden heap.
|
|
490
|
+
#
|
|
491
|
+
# heap_eden_slots
|
|
492
|
+
# : The total number of slots in all of the pages in the eden heap.
|
|
493
|
+
#
|
|
494
|
+
# heap_tomb_pages
|
|
495
|
+
# : The number of pages in the tomb heap. The tomb heap only contains pages
|
|
496
|
+
# that do not have any live objects.
|
|
497
|
+
#
|
|
498
|
+
# heap_tomb_slots
|
|
499
|
+
# : The total number of slots in all of the pages in the tomb heap.
|
|
500
|
+
#
|
|
501
|
+
# total_allocated_pages
|
|
502
|
+
# : The total number of pages that have been allocated in the heap.
|
|
503
|
+
#
|
|
504
|
+
# total_freed_pages
|
|
505
|
+
# : The total number of pages that have been freed and released back to the
|
|
506
|
+
# system in the heap.
|
|
507
|
+
#
|
|
508
|
+
# force_major_gc_count
|
|
509
|
+
# : The number of times this heap has forced major garbage collection cycles
|
|
510
|
+
# to start due to running out of free slots.
|
|
511
|
+
#
|
|
512
|
+
# force_incremental_marking_finish_count
|
|
513
|
+
# : The number of times this heap has forced incremental marking to complete
|
|
514
|
+
# due to running out of pooled slots.
|
|
593
515
|
#
|
|
594
516
|
def self.stat_heap: (?Integer? heap_name, ?Hash[Symbol, untyped]? hash) -> Hash[Symbol, untyped]
|
|
595
517
|
| (Integer heap_name, Symbol key) -> Integer
|
|
@@ -610,67 +532,37 @@ module GC
|
|
|
610
532
|
|
|
611
533
|
# <!--
|
|
612
534
|
# rdoc-file=gc.rb
|
|
613
|
-
# - GC.stress ->
|
|
535
|
+
# - GC.stress -> integer, true, or false
|
|
614
536
|
# -->
|
|
615
|
-
# Returns the current GC stress
|
|
616
|
-
#
|
|
617
|
-
# The stress mode may be set by method GC.stress=.
|
|
537
|
+
# Returns the current status of GC stress mode.
|
|
618
538
|
#
|
|
619
539
|
def self.stress: () -> (Integer | bool)
|
|
620
540
|
|
|
621
541
|
# <!--
|
|
622
542
|
# rdoc-file=gc.rb
|
|
623
|
-
# - GC.stress =
|
|
543
|
+
# - GC.stress = flag -> flag
|
|
624
544
|
# -->
|
|
625
|
-
#
|
|
626
|
-
# performance; it is only for debugging.
|
|
627
|
-
#
|
|
628
|
-
# Sets the current GC stress mode to the given value:
|
|
545
|
+
# Updates the GC stress mode.
|
|
629
546
|
#
|
|
630
|
-
#
|
|
631
|
-
#
|
|
632
|
-
# below.
|
|
633
|
-
# * Otherwise, enables stress mode; GC is invoked at every GC opportunity: all
|
|
634
|
-
# memory and object allocations.
|
|
547
|
+
# When stress mode is enabled, the GC is invoked at every GC opportunity: all
|
|
548
|
+
# memory and object allocations.
|
|
635
549
|
#
|
|
636
|
-
#
|
|
550
|
+
# Enabling stress mode will degrade performance; it is only for debugging.
|
|
637
551
|
#
|
|
638
|
-
#
|
|
639
|
-
#
|
|
640
|
-
#
|
|
552
|
+
# The flag can be true, false, or an integer bitwise-ORed with the following
|
|
553
|
+
# flags:
|
|
554
|
+
# 0x01:: no major GC
|
|
555
|
+
# 0x02:: no immediate sweep
|
|
556
|
+
# 0x04:: full mark after malloc/calloc/realloc
|
|
641
557
|
#
|
|
642
558
|
def self.stress=: (Integer flag) -> Integer
|
|
643
559
|
| (bool flag) -> bool
|
|
644
560
|
|
|
645
561
|
# <!--
|
|
646
562
|
# rdoc-file=gc.rb
|
|
647
|
-
# - GC.total_time ->
|
|
563
|
+
# - GC.total_time -> int
|
|
648
564
|
# -->
|
|
649
|
-
# Returns the GC total time in nanoseconds
|
|
650
|
-
#
|
|
651
|
-
# GC.total_time # => 156250
|
|
652
|
-
#
|
|
653
|
-
# Note that total time accumulates only when total time measurement is enabled
|
|
654
|
-
# (that is, when GC.measure_total_time is `true`):
|
|
655
|
-
#
|
|
656
|
-
# GC.measure_total_time # => true
|
|
657
|
-
# GC.total_time # => 625000
|
|
658
|
-
# GC.start
|
|
659
|
-
# GC.total_time # => 937500
|
|
660
|
-
# GC.start
|
|
661
|
-
# GC.total_time # => 1093750
|
|
662
|
-
#
|
|
663
|
-
# GC.measure_total_time = false
|
|
664
|
-
# GC.total_time # => 1250000
|
|
665
|
-
# GC.start
|
|
666
|
-
# GC.total_time # => 1250000
|
|
667
|
-
# GC.start
|
|
668
|
-
# GC.total_time # => 1250000
|
|
669
|
-
#
|
|
670
|
-
# GC.measure_total_time = true
|
|
671
|
-
# GC.total_time # => 1250000
|
|
672
|
-
# GC.start
|
|
673
|
-
# GC.total_time # => 1406250
|
|
565
|
+
# Returns the measured GC total time in nanoseconds.
|
|
674
566
|
#
|
|
675
567
|
def self.total_time: () -> Integer
|
|
676
568
|
|
|
@@ -727,45 +619,17 @@ module GC
|
|
|
727
619
|
|
|
728
620
|
# <!--
|
|
729
621
|
# rdoc-file=gc.rb
|
|
730
|
-
# - GC.latest_gc_info ->
|
|
731
|
-
# - GC.latest_gc_info(key) -> value
|
|
622
|
+
# - GC.latest_gc_info -> hash
|
|
732
623
|
# - GC.latest_gc_info(hash) -> hash
|
|
624
|
+
# - GC.latest_gc_info(key) -> value
|
|
733
625
|
# -->
|
|
734
|
-
#
|
|
735
|
-
#
|
|
736
|
-
#
|
|
737
|
-
#
|
|
738
|
-
#
|
|
739
|
-
#
|
|
740
|
-
#
|
|
741
|
-
# gc_by: :method,
|
|
742
|
-
# have_finalizer: false,
|
|
743
|
-
# immediate_sweep: true,
|
|
744
|
-
# state: :none,
|
|
745
|
-
# weak_references_count: 0,
|
|
746
|
-
# retained_weak_references_count: 0}
|
|
747
|
-
#
|
|
748
|
-
# With symbol argument `key` given, returns the value for that key:
|
|
749
|
-
#
|
|
750
|
-
# GC.latest_gc_info(:gc_by) # => :newobj
|
|
751
|
-
#
|
|
752
|
-
# With hash argument `hash` given, returns that hash with GC information merged
|
|
753
|
-
# into its content; this form may be useful in minimizing [probe
|
|
754
|
-
# effects](https://en.wikipedia.org/wiki/Probe_effect):
|
|
755
|
-
#
|
|
756
|
-
# h = {foo: 0, bar: 1}
|
|
757
|
-
# GC.latest_gc_info(h)
|
|
758
|
-
# # =>
|
|
759
|
-
# {foo: 0,
|
|
760
|
-
# bar: 1,
|
|
761
|
-
# major_by: nil,
|
|
762
|
-
# need_major_by: nil,
|
|
763
|
-
# gc_by: :newobj,
|
|
764
|
-
# have_finalizer: false,
|
|
765
|
-
# immediate_sweep: false,
|
|
766
|
-
# state: :sweeping,
|
|
767
|
-
# weak_references_count: 0,
|
|
768
|
-
# retained_weak_references_count: 0}
|
|
626
|
+
# Returns information about the most recent garbage collection.
|
|
627
|
+
#
|
|
628
|
+
# If the argument `hash` is given and is a Hash object, it is overwritten and
|
|
629
|
+
# returned. This is intended to avoid the probe effect.
|
|
630
|
+
#
|
|
631
|
+
# If the argument `key` is given and is a Symbol object, it returns the value
|
|
632
|
+
# associated with the key. This is equivalent to `GC.latest_gc_info[key]`.
|
|
769
633
|
#
|
|
770
634
|
def self.latest_gc_info: (?Hash[Symbol, untyped]? hash) -> Hash[Symbol, untyped]
|
|
771
635
|
| (Symbol key) -> untyped
|