allocation_tracer 0.3.3 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1a8521b2ac3ab75ead4770b8aa3b9982f8467d84
4
- data.tar.gz: a4b23c68be89223a669d149cf08bd6105cbcaf7e
3
+ metadata.gz: 94f2c93cda609ede0ad42efbd3fa6121f99e5059
4
+ data.tar.gz: a17dd435501dcce52e55fbf081201cbc80f1c724
5
5
  SHA512:
6
- metadata.gz: 58e5ab416b474b20fedef2a0a99e39d0da0dde7074f50a28047e0205240aa4ae660e9c4df114acfcacf496d657d6cc660b8fbaf4353369c5d400b3b70ab14d78
7
- data.tar.gz: c4176f951ee62200e6e4faace8b9c5e7d0240d8bf4217a868d120758eed8725ba007e059d7af62c7bfe1835a18b953a46cb7adf3db9b23863d4cc9a5ca336776
6
+ metadata.gz: 2a76d3201a4aed46cd935b0a6339a4138c9ba45d13f74e5228e0bc30320f68790720f29ad3ed389f21a3c24c0f382369a4966d325b23d290e163bc98b389650b
7
+ data.tar.gz: 2979c9185bb4ad81bb7b1f7cea46fbe2763ce0eec45b807f1b7b071f68a793b682a089153c2438664f35b4e4a4ca1ae01a1723a19e97beae52b1406083854433
@@ -24,6 +24,8 @@ struct traceobj_arg {
24
24
 
25
25
  /* */
26
26
  size_t **lifetime_table;
27
+ size_t allocated_count_table[T_MASK];
28
+ size_t freed_count_table[T_MASK];
27
29
  };
28
30
 
29
31
  struct allocation_info {
@@ -142,6 +144,7 @@ get_traceobj_arg(void)
142
144
  {
143
145
  if (tmp_trace_arg == 0) {
144
146
  tmp_trace_arg = ALLOC_N(struct traceobj_arg, 1);
147
+ MEMZERO(tmp_trace_arg, struct traceobj_arg, 1);
145
148
  tmp_trace_arg->running = 0;
146
149
  tmp_trace_arg->keys = 0;
147
150
  tmp_trace_arg->vals = VAL_COUNT | VAL_OLDCOUNT | VAL_TOTAL_AGE | VAL_MAX_AGE | VAL_MIN_AGE | VAL_MEMSIZE;
@@ -251,6 +254,8 @@ newobj_i(VALUE tpval, void *data)
251
254
  info->line = NUM2INT(line);
252
255
 
253
256
  st_insert(arg->object_table, (st_data_t)obj, (st_data_t)info);
257
+
258
+ arg->allocated_count_table[BUILTIN_TYPE(obj)]++;
254
259
  }
255
260
 
256
261
  /* file, line, type, klass */
@@ -395,6 +400,8 @@ freeobj_i(VALUE tpval, void *data)
395
400
  add_lifetime_table(arg->lifetime_table, BUILTIN_TYPE(obj), info);
396
401
  }
397
402
  }
403
+
404
+ arg->freed_count_table[BUILTIN_TYPE(obj)]++;
398
405
  }
399
406
 
400
407
  static void
@@ -864,6 +871,38 @@ allocation_tracer_lifetime_table(VALUE self)
864
871
  return result;
865
872
  }
866
873
 
874
+ static VALUE
875
+ allocation_tracer_allocated_count_table(VALUE self)
876
+ {
877
+ struct traceobj_arg * arg = get_traceobj_arg();
878
+ VALUE h = rb_hash_new();
879
+ VALUE type;
880
+ int i;
881
+
882
+ for (i=0; i<T_MASK; i++) {
883
+ type = type_sym(i);
884
+ rb_hash_aset(h, ID2SYM(type), SIZET2NUM(arg->allocated_count_table[i]));
885
+ }
886
+
887
+ return h;
888
+ }
889
+
890
+ static VALUE
891
+ allocation_tracer_freed_count_table(VALUE self)
892
+ {
893
+ struct traceobj_arg * arg = get_traceobj_arg();
894
+ VALUE h = rb_hash_new();
895
+ VALUE type;
896
+ int i;
897
+
898
+ for (i=0; i<T_MASK; i++) {
899
+ type = type_sym(i);
900
+ rb_hash_aset(h, ID2SYM(type), SIZET2NUM(arg->freed_count_table[i]));
901
+ }
902
+
903
+ return h;
904
+ }
905
+
867
906
  void
868
907
  Init_allocation_tracer(void)
869
908
  {
@@ -884,4 +923,7 @@ Init_allocation_tracer(void)
884
923
 
885
924
  rb_define_module_function(mod, "lifetime_table_setup", allocation_tracer_lifetime_table_setup, 1);
886
925
  rb_define_module_function(mod, "lifetime_table", allocation_tracer_lifetime_table, 0);
926
+
927
+ rb_define_module_function(mod, "allocated_count_table", allocation_tracer_allocated_count_table, 0);
928
+ rb_define_module_function(mod, "freed_count_table", allocation_tracer_freed_count_table, 0);
887
929
  }
@@ -1,3 +1,3 @@
1
1
  module ObjectSpace::AllocationTracer
2
- VERSION = "0.3.3"
2
+ VERSION = "0.4.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: allocation_tracer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Koichi Sasada
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-26 00:00:00.000000000 Z
11
+ date: 2014-06-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler