Fix `memsize_of_all` to count memory of subclass instances; #5040

`ObjectSpace.memsize_of_all` takes a class and count memory size of all
instances of the class and its subclasses (if any).
parent 667ace2b
...@@ -353,7 +353,8 @@ static int ...@@ -353,7 +353,8 @@ static int
os_memsize_of_all_cb(mrb_state *mrb, struct RBasic *obj, void *d) os_memsize_of_all_cb(mrb_state *mrb, struct RBasic *obj, void *d)
{ {
struct os_memsize_of_all_cb_data *data = (struct os_memsize_of_all_cb_data *)d; struct os_memsize_of_all_cb_data *data = (struct os_memsize_of_all_cb_data *)d;
if(mrb_class_real(obj->c) == data->type) data->t += os_memsize_of_object(mrb, mrb_obj_value(obj)); if(mrb_obj_is_kind_of(mrb, mrb_obj_value(obj), data->type))
data->t += os_memsize_of_object(mrb, mrb_obj_value(obj));
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment