Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is "allocation context"?

I'm a student and I have to do a research about memory leak detection. In many papers they are talking about allocation context. I don't know what it means. I can't find any definition of allocation context (or translation, I'm from Germany).

As an example, a quote from a paper (Detecting Memory Leaks through Introspective Dynamic Behavior Modeling using Machine Learning):

The key idea behind using machine learning is that a leaking object is discernible by observing the lifetimes of other similar objects. That is, an object can be regarded as having leaked when it accrues a high degree of staleness that is not observed from other supposedly similar objects, i.e., objects with the same allocation context.

Or:

To work around this, this work takes inspiration from previous research on object lifetime prediction [4, 20]. According to these works, the lifetime of an object is strongly correlated with its allocation context. Since the staleness of an object is bounded by its lifetime, object staleness is transitively correlated with allocation context.

Could someone explain it to me easy as possible?

EDIT:

The abstract:

This paper expands staleness-based memory leak detection by presenting a machine learning-based framework. The proposed framework is based on an idea that object stal- eness can be better leveraged in regard to similarity of ob- jects; i.e., an object is more likely to have leaked if it shows signicantly high staleness not observed from other similar objects with the same allocation context. A central part of the proposed framework is the modeling of heap objects. To this end, the framework observes the staleness of objects during a representative run of an ap- plication. From the observed data, the framework generates training examples, which also contain instances of hypothet- ical leaks. Via machine learning, the proposed framework replaces the error-prone user-denable staleness predicates used in previous research with a model-based prediction. The framework was tested using both synthetic and real- world examples. Evaluation with synthetic leakage work- loads of SPEC2006 benchmarks shows that the proposed method achieves the optimal accuracy permitted by staleness- based leak detection. Moreover, by incorporating allocation context into the model, the proposed method achieves higher accuracy than is possible with object staleness alone. Evaluation with real-world memory leaks demonstrates that the proposed method is eective for detecting previously re- ported bugs with high accuracy.

like image 373
m.w. Avatar asked May 30 '15 21:05

m.w.


2 Answers

I got a response from one of the authors. The definition is as follows:

allocation context

It refers to the call stack contents at the time of an allocation. For example, if an allocation site is contained in function foo and the function is called from main (during the execution), the allocation context for the allocation site is (main, main: call@foo, foo: malloc(...)).

like image 147
m.w. Avatar answered Oct 16 '22 03:10

m.w.


Consider such C example:

#include <stdlib.h>

void function_which_allocates(void) {
    /* allocate an array of 45 floats */
    float *a = malloc(sizeof(float) * 45);

    /* additional code making use of 'a' */

    /* return to main, having forgotten to free the memory we malloc'd */
}

int main(void) {
    function_which_allocates();

    /* the pointer 'a' no longer exists, and therefore cannot be freed,
     but the memory is still allocated. a leak has occurred. */
}

Allocation context of a is the function_which_allocates.

So, allocation context of a variable is the scope of that variable.

If you are out of scope, you can't free that memory, which leads to memory leak.

like image 24
Adam Stelmaszczyk Avatar answered Oct 16 '22 02:10

Adam Stelmaszczyk