Use object iv table size in calculation
MODIFY
include/mruby/variable.h
include/mruby/variable.h
@@ -35,6 +35,7 @@ mrb_value mrb_vm_cv_get(mrb_state*, mrb_sym);
void mrb_vm_cv_set(mrb_state*, mrb_sym, mrb_value);
mrb_value mrb_vm_const_get(mrb_state*, mrb_sym);
void mrb_vm_const_set(mrb_state*, mrb_sym, mrb_value);
+mrb_int mrb_obj_iv_tbl_memsize(mrb_state*, mrb_value);
MRB_API mrb_value mrb_const_get(mrb_state*, mrb_value, mrb_sym);
MRB_API void mrb_const_set(mrb_state*, mrb_value, mrb_sym, mrb_value);
MRB_API mrb_bool mrb_const_defined(mrb_state*, mrb_value, mrb_sym);

MODIFY
mrbgems/mruby-objectspace/src/mruby_objectspace.c
mrbgems/mruby-objectspace/src/mruby_objectspace.c
@@ -192,7 +192,7 @@ os_memsize_ivar_cb(mrb_state *mrb, mrb_sym _name, mrb_value obj, void *data)
static void
os_memsize_of_ivars(mrb_state* mrb, mrb_value obj, mrb_bool recurse, mrb_int *t)
{
- /* need iv segment table size */
+ (*t) += mrb_obj_iv_tbl_memsize(mrb, obj);
if(recurse) {
mrb_int r = (mrb_int)recurse;
mrb_int *cb_data[2] = { &r, t };

MODIFY
src/variable.c
src/variable.c
** See Copyright Notice in mruby.h
*/
+#include <math.h>
#include <mruby.h>
#include <mruby/array.h>
#include <mruby/class.h>
@@ -1128,6 +1129,14 @@ mrb_class_find_path(mrb_state *mrb, struct RClass *c)
return path;
}
+mrb_int
+mrb_obj_iv_tbl_memsize(mrb_state* mrb, mrb_value obj)
+{
+ return sizeof(iv_tbl) +
+ (sizeof(segment) * ceil(iv_size(mrb, mrb_obj_ptr(obj)->iv)/
+ MRB_IV_SEGMENT_SIZE));
+}
+
#define identchar(c) (ISALNUM(c) || (c) == '_' || !ISASCII(c))
mrb_bool

Use object iv table size in calculation