objspace.c File Reference
`#include <ruby/ruby.h>`
`#include <ruby/st.h>`
`#include <ruby/io.h>`
`#include <ruby/re.h>`
`#include "node.h"`
`#include "gc.h"`
`#include "regint.h"`
`#include "internal.h"`

Go to the source code of this file.

## Data Structures

struct | total_data

## Macros

#define | COUNT_TYPE(t) case t: type = ID2SYM(rb_intern(#t)); break;
#define | COUNT_NODE(n) case n: node = ID2SYM(rb_intern(#n)); break;

## Functions

size_t | rb_str_memsize (VALUE)
size_t | rb_ary_memsize (VALUE)
size_t | rb_io_memsize (const rb_io_t *)
size_t | rb_generic_ivar_memsize (VALUE)
size_t | rb_objspace_data_type_memsize (VALUE obj)
static size_t | memsize_of (VALUE obj)
static VALUE | memsize_of_m (VALUE self, VALUE obj)
static int | total_i (void *vstart, void *vend, size_t stride, void *ptr)
static VALUE | memsize_of_all_m (int argc, VALUE *argv, VALUE self)
static int | set_zero_i (st_data_t key, st_data_t val, st_data_t arg)
static int | cos_i (void *vstart, void *vend, size_t stride, void *data)
static VALUE | count_objects_size (int argc, VALUE *argv, VALUE os)
static int | cn_i (void *vstart, void *vend, size_t stride, void *n)
static VALUE | count_nodes (int argc, VALUE *argv, VALUE os)
static int | cto_i (void *vstart, void *vend, size_t stride, void *data)
static VALUE | count_tdata_objects (int argc, VALUE *argv, VALUE self)
void | Init_objspace (void)

## Macro Definition Documentation

#define COUNT_NODE | ( |  | n | ) | case n: node = ID2SYM(rb_intern(#n)); break;

Referenced by count_nodes().

#define COUNT_TYPE | ( |  | t | ) | case t: type = ID2SYM(rb_intern(#t)); break;

Referenced by count_objects(), and count_objects_size().

## Function Documentation

static int cn_i | ( | void * | vstart,
|  | void * | vend,
|  | size_t | stride,
|  | void * | n
| ) |  |

static

Definition at line 362 of file objspace.c.

References BUILTIN_TYPE, nd_type, RBASIC, T_NODE, and v.

Referenced by count_nodes().

static int cos_i | ( | void * | vstart,
|  | void * | vend,
|  | size_t | stride,
|  | void * | data
| ) |  |

static

Definition at line 258 of file objspace.c.

References BUILTIN_TYPE, memsize_of(), RBASIC, and v.

Referenced by count_objects_size().

static VALUE count_nodes | ( | int | argc,
|  | VALUE * | argv,
|  | VALUE | os
| ) |  |

static

Definition at line 400 of file objspace.c.

References cn_i(), COUNT_NODE, hash(), i, INT2FIX, NODE_ALIAS, NODE_ALLOCA, NODE_AND, NODE_ARGS, NODE_ARGS_AUX, NODE_ARGSCAT, NODE_ARGSPUSH, NODE_ARRAY, NODE_ATTRASGN, NODE_BACK_REF, NODE_BEGIN, NODE_BLOCK, NODE_BLOCK_ARG, NODE_BLOCK_PASS, NODE_BMETHOD, NODE_BREAK, NODE_CALL, NODE_CASE, NODE_CDECL, NODE_CLASS, NODE_COLON2, NODE_COLON3, NODE_CONST, NODE_CVAR, NODE_CVASGN, NODE_CVDECL, NODE_DASGN, NODE_DASGN_CURR, NODE_DEFINED, NODE_DEFN, NODE_DEFS, NODE_DOT2, NODE_DOT3, NODE_DREGX, NODE_DREGX_ONCE, NODE_DSTR, NODE_DSYM, NODE_DVAR, NODE_DXSTR, NODE_ENSURE, NODE_ERRINFO, NODE_EVSTR, NODE_FALSE, NODE_FCALL, NODE_FLIP2, NODE_FLIP3, NODE_FOR, NODE_GASGN, NODE_GVAR, NODE_HASH, NODE_IASGN, NODE_IASGN2, NODE_IF, NODE_IFUNC, NODE_ITER, NODE_IVAR, NODE_LAMBDA, NODE_LASGN, NODE_LAST, NODE_LIT, NODE_LVAR, NODE_MASGN, NODE_MATCH, NODE_MATCH2, NODE_MATCH3, NODE_MEMO, NODE_MODULE, NODE_NEXT, NODE_NIL, NODE_NTH_REF, NODE_OP_ASGN1, NODE_OP_ASGN2, NODE_OP_ASGN_AND, NODE_OP_ASGN_OR, NODE_OPT_ARG, NODE_OPT_N, NODE_OPTBLOCK, NODE_OR, NODE_POSTARG, NODE_POSTEXE, NODE_PRELUDE, NODE_REDO, NODE_RESBODY, NODE_RESCUE, NODE_RETRY, NODE_RETURN, NODE_SCLASS, NODE_SCOPE, NODE_SELF, NODE_SPLAT, NODE_STR, NODE_SUPER, NODE_TO_ARY, NODE_TRUE, NODE_UNDEF, NODE_UNTIL, NODE_VALIAS, NODE_VALUES, NODE_VCALL, NODE_WHEN, NODE_WHILE, NODE_XSTR, NODE_YIELD, NODE_ZARRAY, NODE_ZSUPER, Qnil, rb_eTypeError, rb_hash_aset(), rb_hash_new(), rb_objspace_each_objects(), rb_raise(), rb_scan_args(), RHASH_EMPTY_P, RHASH_TBL, set_zero_i(), SIZET2NUM, st_foreach, T_HASH, and TYPE.

Referenced by Init_objspace().

static VALUE count_objects_size | ( | int | argc,
|  | VALUE * | argv,
|  | VALUE | os
| ) |  |

static

Definition at line 295 of file objspace.c.

References cos_i(), COUNT_TYPE, hash(), i, ID2SYM, INT2NUM(), Qnil, rb_eTypeError, rb_hash_aset(), rb_hash_new(), rb_intern, rb_objspace_each_objects(), rb_raise(), rb_scan_args(), RHASH_EMPTY_P, RHASH_TBL, set_zero_i(), SIZET2NUM, st_foreach, T_ARRAY, T_BIGNUM, T_CLASS, T_COMPLEX, T_DATA, T_FALSE, T_FILE, T_FIXNUM, T_FLOAT, T_HASH, T_ICLASS, T_MASK, T_MATCH, T_MODULE, T_NIL, T_NODE, T_NONE, T_OBJECT, T_RATIONAL, T_REGEXP, T_STRING, T_STRUCT, T_SYMBOL, T_TRUE, T_UNDEF, T_ZOMBIE, total_data::total, type, and TYPE.

Referenced by Init_objspace().

static VALUE count_tdata_objects | ( | int | argc,
|  | VALUE * | argv,
|  | VALUE | self
| ) |  |

static

Definition at line 607 of file objspace.c.

References cto_i(), hash(), Qnil, rb_eTypeError, rb_hash_new(), rb_objspace_each_objects(), rb_raise(), rb_scan_args(), RHASH_EMPTY_P, RHASH_TBL, set_zero_i(), st_foreach, T_HASH, and TYPE.

Referenced by Init_objspace().

static int cto_i | ( | void * | vstart,
|  | void * | vend,
|  | size_t | stride,
|  | void * | data
| ) |  |

static

Definition at line 543 of file objspace.c.

References BUILTIN_TYPE, FIX2INT, hash(), ID2SYM, INT2FIX, name, NIL_P, rb_hash_aref(), rb_hash_aset(), rb_intern, rb_objspace_data_type_name(), RBASIC, T_DATA, and v.

Referenced by count_tdata_objects().

void Init_objspace | ( | void |  | ) |

Definition at line 639 of file objspace.c.

References count_nodes(), count_objects_size(), count_tdata_objects(), memsize_of_all_m(), memsize_of_m(), rb_cObject, rb_const_get(), rb_define_module_function(), and rb_intern.

static size_t memsize_of | ( | VALUE | obj | ) |

static

Definition at line 42 of file objspace.c.

References BDIGIT, BUILTIN_TYPE, rmatch::char_offset_num_allocated, FL_EXIVAR, FL_TEST, nd_type, NODE_ALLOCA, NODE_SCOPE, onig_memsize(), rb_ary_memsize(), rb_bug(), rb_generic_ivar_memsize(), rb_io_memsize(), rb_objspace_data_type_memsize(), rb_str_memsize(), RBASIC, RBIGNUM_DIGITS, RBIGNUM_EMBED_FLAG, RBIGNUM_LEN, RCLASS, RCLASS_IV_INDEX_TBL, RCLASS_IV_TBL, RCLASS_M_TBL, RFILE, RHASH, RMATCH, RNODE, ROBJECT, ROBJECT_EMBED, RREGEXP, RSTRUCT, RSTRUCT_EMBED_LEN_MASK, RSTRUCT_LEN, size, SPECIAL_CONST_P, st_memsize(), T_ARRAY, T_BIGNUM, T_CLASS, T_COMPLEX, T_DATA, T_FILE, T_FLOAT, T_HASH, T_ICLASS, T_MATCH, T_MODULE, T_NODE, T_OBJECT, T_RATIONAL, T_REGEXP, T_STRING, T_STRUCT, and T_ZOMBIE.

Referenced by cos_i(), memsize_of_m(), and total_i().

static VALUE memsize_of_all_m | ( | int | argc,
|  | VALUE * | argv,
|  | VALUE | self
| ) |  |

static

Definition at line 236 of file objspace.c.

References total_data::klass, rb_objspace_each_objects(), rb_scan_args(), SIZET2NUM, total_data::total, and total_i().

Referenced by Init_objspace().

static VALUE memsize_of_m | ( | VALUE | self,
|  | VALUE | obj
| ) |  |

static

Definition at line 170 of file objspace.c.

References memsize_of(), and SIZET2NUM.

Referenced by Init_objspace().

size_t rb_ary_memsize | ( | VALUE |  | ) |

Definition at line 394 of file array.c.

References ARY_OWNS_HEAP_P, and RARRAY.

Referenced by memsize_of().

size_t rb_generic_ivar_memsize | ( | VALUE |  | ) |

Definition at line 950 of file variable.c.

References st_lookup, and st_memsize().

Referenced by memsize_of().

size_t rb_io_memsize | ( | const rb_io_t * |  | ) |

Definition at line 3796 of file io.c.

References rb_io_buffer_t::capa, rb_io_t::cbuf, rb_econv_memsize(), rb_io_t, rb_io_t::rbuf, rb_io_t::readconv, size, rb_io_t::wbuf, and rb_io_t::writeconv.

Referenced by memsize_of().

size_t rb_objspace_data_type_memsize | ( | VALUE | obj | ) |

Definition at line 1247 of file gc.c.

Referenced by memsize_of().

size_t rb_str_memsize | ( | VALUE |  | ) |

Definition at line 797 of file string.c.

References RSTRING, STR_EMBED_P, and STR_SHARED_P.

Referenced by memsize_of().

static int set_zero_i | ( | st_data_t | key,
|  | st_data_t | val,
|  | st_data_t | arg
| ) |  |

static

Definition at line 249 of file objspace.c.

References hash(), INT2FIX, rb_hash_aset(), and ST_CONTINUE.

Referenced by count_nodes(), count_objects_size(), and count_tdata_objects().

static int total_i | ( | void * | vstart,
|  | void * | vend,
|  | size_t | stride,
|  | void * | ptr
| ) |  |

static

Definition at line 181 of file objspace.c.

References BUILTIN_TYPE, FL_SINGLETON, FL_TEST, total_data::klass, memsize_of(), rb_obj_is_kind_of(), RBASIC, T_CLASS, T_ICLASS, T_NODE, T_NONE, T_ZOMBIE, total_data::total, and v.

Referenced by memsize_of_all_m().