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
1170 1171 1172 1173 |
# File 'ext/mwrap/mwrap.c', line 1170
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+
1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 |
# File 'ext/mwrap/mwrap.c', line 1138
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
1164 1165 1166 1167 |
# File 'ext/mwrap/mwrap.c', line 1164
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.
1185 1186 1187 1188 |
# File 'ext/mwrap/mwrap.c', line 1185
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.
1153 1154 1155 1156 1157 1158 1159 1160 1161 |
# File 'ext/mwrap/mwrap.c', line 1153
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.
1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 |
# File 'ext/mwrap/mwrap.c', line 1193
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
1176 1177 1178 1179 |
# File 'ext/mwrap/mwrap.c', line 1176
static VALUE src_loc_total(VALUE self)
{
return SIZET2NUM(uatomic_read(&src_loc_get(self)->total));
}
|