Class: Rbkit::RbkitGC
- Inherits:
-
Object
- Object
- Rbkit::RbkitGC
- Defined in:
- lib/rbkit/rbkit_gc.rb
Class Method Summary collapse
-
.stat ⇒ Hash
Returns a standardized hash containing the data returned by GC.stat.
Class Method Details
.stat ⇒ Hash
Returns a standardized hash containing the data returned by GC.stat
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/rbkit/rbkit_gc.rb', line 30 def self.stat stats = {} data = GC.stat stats[:count] = data[:count] stats[:minor_gc_count] = data[:minor_gc_count] stats[:major_gc_count] = data[:major_gc_count] if RUBY_VERSION >= "2.2.0" [ :heap_allocated_pages, :heap_eden_pages, :heap_tomb_pages, :heap_allocatable_pages, :heap_sorted_length, :heap_live_slots, :heap_free_slots, :heap_final_slots, :heap_swept_slots, :old_objects, :old_objects_limit, :total_allocated_objects, :total_freed_objects, :malloc_increase_bytes, :malloc_increase_bytes_limit, :oldmalloc_increase_bytes, :oldmalloc_increase_bytes_limit ].each do |key| stats[key] = data[key] end elsif RUBY_VERSION >= "2.1.0" stats[:heap_allocated_pages] = data[:heap_used] stats[:heap_eden_pages] = data[:heap_eden_page_length] stats[:heap_tomb_pages] = data[:heap_tomb_page_length] stats[:heap_allocatable_pages] = data[:heap_increment] stats[:heap_sorted_length] = data[:heap_length] stats[:heap_live_slots] = data[:heap_live_slot] stats[:heap_free_slots] = data[:heap_free_slot] stats[:heap_final_slots] = data[:heap_final_slot] stats[:heap_swept_slots] = data[:heap_swept_slot] stats[:old_objects] = data[:old_object] stats[:old_objects_limit] = data[:old_object_limit] stats[:total_allocated_objects] = data[:total_allocated_object] stats[:total_freed_objects] = data[:total_freed_object] stats[:malloc_increase_bytes] = data[:malloc_increase] stats[:malloc_increase_bytes_limit] = data[:malloc_limit] stats[:oldmalloc_increase_bytes] = data[:oldmalloc_increase] stats[:oldmalloc_increase_bytes_limit] = data[:oldmalloc_limit] end no_of_allocated_pages = stats[:heap_allocated_pages] rescue 0 max_objects_per_page = GC::INTERNAL_CONSTANTS[:HEAP_OBJ_LIMIT] size_of_one_obj = GC::INTERNAL_CONSTANTS[:RVALUE_SIZE] stats[:total_heap_size] = no_of_allocated_pages * max_objects_per_page * size_of_one_obj stats[:total_memsize] = ObjectSpace.memsize_of_all stats end |