Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
diff --git a/gc.c b/gc.c
index 7f65b98..8498fe4 100644
--- a/gc.c
+++ b/gc.c
@@ -281,7 +281,6 @@ getrusage_time(void)
#define GC_PROF_DEC_LIVE_NUM
#endif
-
#if defined(_MSC_VER) || defined(__BORLANDC__) || defined(__CYGWIN__)
#pragma pack(push, 1) /* magic for reducing sizeof(RVALUE): 24 -> 20 */
#endif
@@ -1562,6 +1561,24 @@ rb_gc_time()
#endif
}
+/*
+ * call-seq:
+ * GC.heap_slots_live_after_last_gc => Integer
+ *
+ * Returns the number of heap slots which were live after the last garbage collection.
+ *
+ * GC.heap_slots_live_after_last_gc #=> 231223
+ *
+ */
+VALUE
+rb_gc_heap_slots_live_after_last_gc()
+{
+ rb_objspace_t *objspace = &rb_objspace;
+ return ULONG2NUM(live_after_last_mark_phase);
+}
+
+
+
VALUE rb_mGC;
void
@@ -4533,6 +4550,7 @@ Init_GC(void)
rb_define_singleton_method(rb_mGC, "allocated_size", rb_gc_allocated_size, 0);
rb_define_singleton_method(rb_mGC, "num_allocations", rb_gc_num_allocations, 0);
rb_define_singleton_method(rb_mGC, "heap_slots", rb_gc_heap_slots, 0);
+ rb_define_singleton_method(rb_mGC, "heap_slots_live_after_last_gc", rb_gc_heap_slots_live_after_last_gc, 0);
rb_define_const(rb_mGC, "HEAP_SLOT_SIZE", INT2FIX(sizeof(RVALUE)));
rb_define_singleton_method(rb_mGC, "log", rb_gc_log, 1);