diff options
author | Peter Zhu <peter@peterzhu.ca> | 2022-01-04 08:59:32 -0500 |
---|---|---|
committer | Peter Zhu <peter@peterzhu.ca> | 2022-01-04 09:46:36 -0500 |
commit | 615e9b28658c5b44a4474e04a53b84ae83b8e3fd (patch) | |
tree | 90f2f045c6f4d1d65f8361ff59fa3593b395f701 /gc.rb | |
parent | e9a4cc02b491fc8a2936f51b9f94ddcd77dd67f7 (diff) |
[Feature #18364] Add GC.stat_heap to get stats for memory heaps
GC.stat_heap will return stats for memory heaps. This is
used for the Variable Width Allocation feature.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/5177
Diffstat (limited to 'gc.rb')
-rw-r--r-- | gc.rb | 34 |
1 files changed, 34 insertions, 0 deletions
@@ -205,6 +205,40 @@ module GC Primitive.gc_stat hash_or_key end + # call-seq: + # GC.stat_heap -> Hash + # GC.stat_heap(nil, hash) -> Hash + # GC.stat_heap(heap_name) -> Hash + # GC.stat_heap(heap_name, hash) -> Hash + # GC.stat_heap(heap_name, :key) -> Numeric + # + # Returns information for memory pools in the GC. + # + # If the first optional argument, +heap_name+, is passed in and not +nil+, it + # returns a +Hash+ containing information about the particular memory pool. + # Otherwise, it will return a +Hash+ with memory pool names as keys and + # a +Hash+ containing information about the memory pool as values. + # + # If the second optional argument, +hash_or_key+, is given as +Hash+, it will + # be overwritten and returned. This is intended to avoid the probe effect. + # + # If both optional arguments are passed in and the second optional argument is + # a symbol, it will return a +Numeric+ of the value for the particular memory + # pool. + # + # On CRuby, +heap_name+ is of the type +Integer+ but may be of type +String+ + # on other implementations. + # + # The contents of the hash are implementation specific and may change in + # the future without notice. + # + # If the optional argument, hash, is given, it is overwritten and returned. + # + # This method is only expected to work on CRuby. + def self.stat_heap heap_name = nil, hash_or_key = nil + Primitive.gc_stat_heap heap_name, hash_or_key + end + # call-seq: # GC.latest_gc_info -> {:gc_by=>:newobj} # GC.latest_gc_info(hash) -> hash |