Class: Mwrap::SourceLocation
- Inherits:
-
Object
- Object
- Mwrap::SourceLocation
- Defined in:
- ext/mwrap/mwrap.c
Instance Method Summary collapse
-
#allocations ⇒ Object
The number of allocations made from this location.
-
#each ⇒ Object
loc = Mwrap loc.each { |size,generation| … }.
-
#frees ⇒ Object
The number of frees made from this location.
-
#max_lifespan ⇒ Object
The maximum age (in GC generations) of an allocation before it was freed.
-
#mean_lifespan ⇒ Object
The the mean lifespan (in GC generations) of allocations made from this location.
-
#name ⇒ Object
Returns a frozen String location of the given SourceLocation object.
-
#total ⇒ Object
The total number of bytes allocated from this location.
Instance Method Details
#allocations ⇒ Object
The number of allocations made from this location
1140 1141 1142 1143 |
# File 'ext/mwrap/mwrap.c', line 1140
static VALUE src_loc_allocations(VALUE self)
{
return SIZET2NUM(uatomic_read(&src_loc_get(self)->allocations));
}
|
#each ⇒ Object
loc = Mwrap loc.each { |size,generation| … }
Iterates through live allocations for a given Mwrap::SourceLocation, yielding the size (in bytes) and generation of each allocation. The generation is the value of the GC.count method at the time the allocation was made.
This functionality is only available in mwrap 2.0.0+
1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 |
# File 'ext/mwrap/mwrap.c', line 1108
static VALUE src_loc_each(VALUE self)
{
struct src_loc *l = src_loc_get(self);
assert(locating == 0 && "forgot to clear locating");
++locating;
rcu_read_lock();
rb_ensure(src_loc_each_i, (VALUE)l, rcu_unlock_ensure, 0);
return self;
}
|
#frees ⇒ Object
The number of frees made from this location
1134 1135 1136 1137 |
# File 'ext/mwrap/mwrap.c', line 1134
static VALUE src_loc_frees(VALUE self)
{
return SIZET2NUM(uatomic_read(&src_loc_get(self)->frees));
}
|
#max_lifespan ⇒ Object
The maximum age (in GC generations) of an allocation before it was freed. This does not account for live allocations.
1155 1156 1157 1158 |
# File 'ext/mwrap/mwrap.c', line 1155
static VALUE src_loc_max_lifespan(VALUE self)
{
return SIZET2NUM(uatomic_read(&src_loc_get(self)->max_lifespan));
}
|
#mean_lifespan ⇒ Object
The the mean lifespan (in GC generations) of allocations made from this location. This does not account for live allocations.
1123 1124 1125 1126 1127 1128 1129 1130 1131 |
# File 'ext/mwrap/mwrap.c', line 1123
static VALUE src_loc_mean_lifespan(VALUE self)
{
struct src_loc *l = src_loc_get(self);
size_t tot, frees;
frees = uatomic_read(&l->frees);
tot = uatomic_read(&l->age_total);
return DBL2NUM(frees ? ((double)tot/(double)frees) : HUGE_VAL);
}
|
#name ⇒ Object
Returns a frozen String location of the given SourceLocation object.
1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 |
# File 'ext/mwrap/mwrap.c', line 1163
static VALUE src_loc_name(VALUE self)
{
struct src_loc *l = src_loc_get(self);
VALUE ret;
++locating;
ret = location_string(l);
--locating;
return ret;
}
|
#total ⇒ Object
The total number of bytes allocated from this location
1146 1147 1148 1149 |
# File 'ext/mwrap/mwrap.c', line 1146
static VALUE src_loc_total(VALUE self)
{
return SIZET2NUM(uatomic_read(&src_loc_get(self)->total));
}
|