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
980 981 982 983 |
# File 'ext/mwrap/mwrap.c', line 980
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+
948 949 950 951 952 953 954 955 956 957 |
# File 'ext/mwrap/mwrap.c', line 948
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
974 975 976 977 |
# File 'ext/mwrap/mwrap.c', line 974
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.
995 996 997 998 |
# File 'ext/mwrap/mwrap.c', line 995
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.
963 964 965 966 967 968 969 970 971 |
# File 'ext/mwrap/mwrap.c', line 963
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.
1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 |
# File 'ext/mwrap/mwrap.c', line 1003
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
986 987 988 989 |
# File 'ext/mwrap/mwrap.c', line 986
static VALUE src_loc_total(VALUE self)
{
return SIZET2NUM(uatomic_read(&src_loc_get(self)->total));
}
|