summaryrefslogtreecommitdiff
path: root/gc.c
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-05-24 06:46:44 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-05-24 06:46:44 +0000
commit9e1624cfe8880fc018e34327c77669f2f4e5b100 (patch)
tree1f1ec71af916b8b0472ab9193d6d87b5bd8f41ce /gc.c
parent144e06700705a3f067582682567bc77b429c4fca (diff)
Add debug counters.
* debug_counter.h: add the following counters to measure object types. obj_free: freed count obj_str_ptr: freed count of Strings they have extra buff. obj_str_embed: freed count of Strings they don't have extra buff. obj_str_shared: freed count of Strings they have shared extra buff. obj_str_nofree: freed count of Strings they are marked as nofree. obj_str_fstr: freed count of Strings they are marked as fstr. obj_ary_ptr: freed count of Arrays they have extra buff. obj_ary_embed: freed count of Arrays they don't have extra buff. obj_obj_ptr: freed count of Objects (T_OBJECT) they have extra buff. obj_obj_embed: freed count of Objects they don't have extra buff. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58865 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'gc.c')
-rw-r--r--gc.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/gc.c b/gc.c
index f0fb88d320..77d84a7f91 100644
--- a/gc.c
+++ b/gc.c
@@ -33,6 +33,7 @@
#include <setjmp.h>
#include <sys/types.h>
#include "ruby_assert.h"
+#include "debug_counter.h"
#undef rb_data_object_wrap
@@ -2103,6 +2104,8 @@ make_io_zombie(rb_objspace_t *objspace, VALUE obj)
static int
obj_free(rb_objspace_t *objspace, VALUE obj)
{
+ RB_DEBUG_COUNTER_INC(obj_free);
+
gc_event_hook(objspace, RUBY_INTERNAL_EVENT_FREEOBJ, obj);
switch (BUILTIN_TYPE(obj)) {
@@ -2137,6 +2140,10 @@ obj_free(rb_objspace_t *objspace, VALUE obj)
if (!(RANY(obj)->as.basic.flags & ROBJECT_EMBED) &&
RANY(obj)->as.object.as.heap.ivptr) {
xfree(RANY(obj)->as.object.as.heap.ivptr);
+ RB_DEBUG_COUNTER_INC(obj_obj_ptr);
+ }
+ else {
+ RB_DEBUG_COUNTER_INC(obj_obj_embed);
}
break;
case T_MODULE: