[aspectc-user] capturing memory allocations
Olaf Spinczyk
Olaf.Spinczyk at informatik.uni-erlangen.de
Tue Mar 22 12:52:05 CET 2005
Hi Tiago,
Tiago Rodrigues wrote:
> Hi, i'm new to aspectc,
> i'm trying to capture heap memory allocations to do a sort of memory profiller.
> My problem is that my advices don't get applied to the code.
>
> Here is an example:
>
> aspect:
> [CODE]
> aspect MemProf
> {
> advice call("% operator new(...)") || call("% %::operator
> new(...)") : before()
> {
> std::cout << "call to new()" << std::endl;
> }
> };
> [/CODE]
>
> sample code:
> [CODE]
> int main()
> {
> class Test {};
> Test *t = new Test;
> int *i = new int[10];
> delete[] i;
> delete t;
> return 0;
> }
> [/CODE]
>
> the advice isn't being applied to the new calls.
> anyone can help?
>
> using: ac-0.9.2, on linux
> gcc version: 3.4.3
>
> thanks in advance,
> Tiago R.
you are right. call(...) does not match any 'new ...'. The reason is
that we don't consider an object instantiation on the heap to be a call.
We have started to provide support for join points related to object
instantiation with construction and destruction advice. A client-side
construction/destruction advice is still missing :-(.
For now, I can only recommend to do it the classical way, i.e. by
implementing your own new operator, which you link with your
application. Maybe construction/destruction advice also helps you,
although you are only able to destinguish between automatic variable
allocation and heap allocation by checking the object address.
Olaf
More information about the aspectc-user
mailing list