@@ -157,6 +157,61 @@ module GC
157157 #
158158 OPTS: Array[String]
159159
160+ # <!--
161+ # rdoc-file=gc.rb
162+ # - GC.config -> hash
163+ # - GC.config(hash) -> hash
164+ # -->
165+ # Sets or gets information about the current GC config.
166+ #
167+ # Configuration parameters are GC implementation-specific and may change without
168+ # notice.
169+ #
170+ # This method can be called without parameters to retrieve the current config.
171+ #
172+ # This method can also be called with a `Hash` argument to assign values to
173+ # valid config keys. Config keys missing from the passed `Hash` will be left
174+ # unmodified.
175+ #
176+ # If a key/value pair is passed to this function that does not correspond to a
177+ # valid config key for the GC implementation being used, no config will be
178+ # updated, the key will be present in the returned Hash, and its value will be
179+ # `nil`. This is to facilitate easy migration between GC implementations.
180+ #
181+ # In both call-seqs, the return value of `GC.config` will be a `Hash` containing
182+ # the most recent full configuration, i.e., all keys and values defined by the
183+ # specific GC implementation being used. In the case of a config update, the
184+ # return value will include the new values being updated.
185+ #
186+ # This method is only expected to work on CRuby.
187+ #
188+ # Valid config keys for Ruby's default GC implementation are:
189+ #
190+ # rgengc_allow_full_mark
191+ # : Controls whether the GC is allowed to run a full mark (young & old
192+ # objects).
193+ #
194+ # When `true`, GC interleaves major and minor collections. This is the
195+ # default. GC will function as intended.
196+ #
197+ # When `false`, the GC will never trigger a full marking cycle unless
198+ # explicitly requested by user code. Instead, only a minor mark will
199+ # run—only young objects will be marked. When the heap space is exhausted,
200+ # new pages will be allocated immediately instead of running a full mark.
201+ #
202+ # A flag will be set to notify that a full mark has been requested. This
203+ # flag is accessible using `GC.latest_gc_info(:needs_major_by)`
204+ #
205+ # The user can trigger a major collection at any time using
206+ # `GC.start(full_mark: true)`
207+ #
208+ # When `false`, Young to Old object promotion is disabled. For performance
209+ # reasons, it is recommended to warm up an application using
210+ # `Process.warmup` before setting this parameter to `false`.
211+ #
212+ def self.config : () -> Hash[Symbol, untyped ]
213+ | (Hash[Symbol, untyped ]) -> Hash[Symbol, untyped ]
214+
160215 # <!--
161216 # rdoc-file=gc.rb
162217 # - GC.count -> Integer
0 commit comments