@@ -252,61 +252,142 @@ def self.stat hash_or_key = nil
252252 end
253253
254254 # call-seq:
255- # GC.stat_heap -> Hash
256- # GC.stat_heap(nil, hash ) -> Hash
257- # GC.stat_heap(heap_name ) -> Hash
258- # GC.stat_heap(heap_name , hash) -> Hash
259- # GC.stat_heap(heap_name, :key ) -> Numeric
255+ # GC.stat_heap -> new_hash
256+ # GC.stat_heap(heap_id ) -> new_hash
257+ # GC.stat_heap(heap_id, key ) -> value
258+ # GC.stat_heap(nil , hash) -> hash
259+ # GC.stat_heap(heap_id, hash ) -> hash
260260 #
261- # Returns information for heaps in the \GC .
261+ # This method is implementation-specific to CRuby .
262262 #
263- # If the first optional argument, +heap_name+, is passed in and not +nil+, it
264- # returns a +Hash+ containing information about the particular heap.
265- # Otherwise, it will return a +Hash+ with heap names as keys and
266- # a +Hash+ containing information about the heap as values.
263+ # Returns statistics for \GC heaps.
264+ # The particular statistics are implementation-specific
265+ # and may change in the future without notice.
267266 #
268- # If the second optional argument, +hash_or_key+, is given as a +Hash+, it will
269- # be overwritten and returned. This is intended to avoid the probe effect.
267+ # With no argument given, returns statistics for all heaps:
270268 #
271- # If both optional arguments are passed in and the second optional argument is
272- # a symbol, it will return a +Numeric+ value for the particular heap.
269+ # GC.stat_heap
270+ # # =>
271+ # {0 =>
272+ # {slot_size: 40,
273+ # heap_eden_pages: 246,
274+ # heap_eden_slots: 402802,
275+ # total_allocated_pages: 246,
276+ # force_major_gc_count: 2,
277+ # force_incremental_marking_finish_count: 1,
278+ # total_allocated_objects: 33867152,
279+ # total_freed_objects: 33520523},
280+ # 1 =>
281+ # {slot_size: 80,
282+ # heap_eden_pages: 84,
283+ # heap_eden_slots: 68746,
284+ # total_allocated_pages: 84,
285+ # force_major_gc_count: 1,
286+ # force_incremental_marking_finish_count: 4,
287+ # total_allocated_objects: 147491,
288+ # total_freed_objects: 90699},
289+ # 2 =>
290+ # {slot_size: 160,
291+ # heap_eden_pages: 157,
292+ # heap_eden_slots: 64182,
293+ # total_allocated_pages: 157,
294+ # force_major_gc_count: 0,
295+ # force_incremental_marking_finish_count: 0,
296+ # total_allocated_objects: 211460,
297+ # total_freed_objects: 190075},
298+ # 3 =>
299+ # {slot_size: 320,
300+ # heap_eden_pages: 8,
301+ # heap_eden_slots: 1631,
302+ # total_allocated_pages: 8,
303+ # force_major_gc_count: 0,
304+ # force_incremental_marking_finish_count: 0,
305+ # total_allocated_objects: 1422,
306+ # total_freed_objects: 700},
307+ # 4 =>
308+ # {slot_size: 640,
309+ # heap_eden_pages: 16,
310+ # heap_eden_slots: 1628,
311+ # total_allocated_pages: 16,
312+ # force_major_gc_count: 0,
313+ # force_incremental_marking_finish_count: 0,
314+ # total_allocated_objects: 1230,
315+ # total_freed_objects: 309}}
316+ #
317+ # In the example above, the keys in the outer hash are the heap identifiers:
318+ #
319+ # GC.stat_heap.keys # => [0, 1, 2, 3, 4]
320+ #
321+ # On CRuby, each heap identifier is an integer;
322+ # on other implementations, a heap identifier may be a string.
323+ #
324+ # With only argument +heap_id+ given,
325+ # returns statistics for the given heap identifier:
326+ #
327+ # GC.stat_heap(2)
328+ # # =>
329+ # {slot_size: 160,
330+ # heap_eden_pages: 157,
331+ # heap_eden_slots: 64182,
332+ # total_allocated_pages: 157,
333+ # force_major_gc_count: 0,
334+ # force_incremental_marking_finish_count: 0,
335+ # total_allocated_objects: 225018,
336+ # total_freed_objects: 206647}
273337 #
274- # On CRuby, +heap_name+ is of the type +Integer+ but may be of type +String+
275- # on other implementations.
338+ # With arguments +heap_id+ and +key+ given,
339+ # returns the value for the given key in the given heap:
276340 #
277- # The contents of the hash are implementation-specific and may change in
278- # the future without notice.
341+ # GC.stat_heap(2, :slot_size) # => 160
279342 #
280- # If the optional argument, hash, is given, it is overwritten and returned.
343+ # With arguments +nil+ and +hash+ given,
344+ # merges the statistics for all heaps into the given hash:
281345 #
282- # This method is only expected to work on CRuby.
346+ # h = {foo: 0, bar: 1}
347+ # GC.stat_heap(nil, h).keys # => [:foo, :bar, 0, 1, 2, 3, 4]
283348 #
284- # The hash includes the following keys about the internal information in
285- # the \GC :
349+ # With arguments +heap_id+ and +hash+ given,
350+ # merges the statistics for the given heap into the given hash :
286351 #
287- # [slot_size]
352+ # h = {foo: 0, bar: 1}
353+ # GC.stat_heap(2, h).keys
354+ # # =>
355+ # [:foo,
356+ # :bar,
357+ # :slot_size,
358+ # :heap_eden_pages,
359+ # :heap_eden_slots,
360+ # :total_allocated_pages,
361+ # :force_major_gc_count,
362+ # :force_incremental_marking_finish_count,
363+ # :total_allocated_objects,
364+ # :total_freed_objects]
365+ #
366+ # The statistics for a heap may include:
367+ #
368+ # - +:slot_size+:
288369 # The slot size of the heap in bytes.
289- # [ heap_allocatable_pages]
370+ # - +: heap_allocatable_pages+:
290371 # The number of pages that can be allocated without triggering a new
291372 # garbage collection cycle.
292- # [ heap_eden_pages]
373+ # - +: heap_eden_pages+:
293374 # The number of pages in the eden heap.
294- # [ heap_eden_slots]
375+ # - +: heap_eden_slots+:
295376 # The total number of slots in all of the pages in the eden heap.
296- # [ heap_tomb_pages]
377+ # - +: heap_tomb_pages+:
297378 # The number of pages in the tomb heap. The tomb heap only contains pages
298379 # that do not have any live objects.
299- # [ heap_tomb_slots]
380+ # - +: heap_tomb_slots+:
300381 # The total number of slots in all of the pages in the tomb heap.
301- # [ total_allocated_pages]
382+ # - +: total_allocated_pages+:
302383 # The total number of pages that have been allocated in the heap.
303- # [ total_freed_pages]
384+ # - +: total_freed_pages+:
304385 # The total number of pages that have been freed and released back to the
305386 # system in the heap.
306- # [ force_major_gc_count]
387+ # - +: force_major_gc_count+:
307388 # The number of times this heap has forced major garbage collection cycles
308389 # to start due to running out of free slots.
309- # [ force_incremental_marking_finish_count]
390+ # - +: force_incremental_marking_finish_count+:
310391 # The number of times this heap has forced incremental marking to complete
311392 # due to running out of pooled slots.
312393 #
0 commit comments