Skip to content

Commit 61c372a

Browse files
committed
[DOC] Improve docs for ObjectSpace.count_symbols
1 parent 1267a3a commit 61c372a

File tree

1 file changed

+15
-16
lines changed

1 file changed

+15
-16
lines changed

ext/objspace/objspace.c

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -295,28 +295,27 @@ size_t rb_sym_immortal_count(void);
295295

296296
/*
297297
* call-seq:
298-
* ObjectSpace.count_symbols([result_hash]) -> hash
298+
* ObjectSpace.count_symbols(result_hash = nil) -> hash
299299
*
300-
* Counts symbols for each Symbol type.
300+
* Returns a hash containing the number of objects for each Symbol type.
301301
*
302-
* This method is only for MRI developers interested in performance and memory
303-
* usage of Ruby programs.
302+
* The types of Symbols are the following:
304303
*
305-
* If the optional argument, result_hash, is given, it is overwritten and
306-
* returned. This is intended to avoid probe effect.
304+
* - +mortal_dynamic_symbol+: Symbols that are garbage collectable.
305+
* - +immortal_dynamic_symbol+: Symbols that are objects allocated from the
306+
* garbage collector, but are not garbage collectable.
307+
* - +immortal_static_symbol+: Symbols that are not allocated from the
308+
* garbage collector, and are thus not garbage collectable.
309+
* - +immortal_symbol+: the sum of +immortal_dynamic_symbol+ and +immortal_static_symbol+.
307310
*
308-
* Note:
309-
* The contents of the returned hash is implementation defined.
310-
* It may be changed in future.
311-
*
312-
* This method is only expected to work with C Ruby.
311+
* If the optional argument +result_hash+ is given, it is overwritten and
312+
* returned. This is intended to avoid the probe effect.
313313
*
314-
* On this version of MRI, they have 3 types of Symbols (and 1 total counts).
314+
* This method is intended for developers interested in performance and memory
315+
* usage of Ruby programs. The contents of the returned hash is implementation
316+
* specific and may change in the future.
315317
*
316-
* * mortal_dynamic_symbol: GC target symbols (collected by GC)
317-
* * immortal_dynamic_symbol: Immortal symbols promoted from dynamic symbols (do not collected by GC)
318-
* * immortal_static_symbol: Immortal symbols (do not collected by GC)
319-
* * immortal_symbol: total immortal symbols (immortal_dynamic_symbol+immortal_static_symbol)
318+
* This method is only expected to work with C Ruby.
320319
*/
321320

322321
static VALUE

0 commit comments

Comments
 (0)