[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Re: please help: heap space ballooning when I use aspectJ with my webapplication

Hi,

> My web application without AspectJ used to always 'stabilize' at 150 to 250
> MB tops (values as seen from windows task manager). With AspectJ and my
> aspects it gets to 750 - 800MB within 2 minutes of browsing.

Sounds like a lot of memory.

> Is there anything informative in the heap dump?

I don't see anything too surprising.  You do show this:

46,663,513 (87%)

and if 87% of your memory is 46M, I don't quite understand the 800Mb
number you mentioned.  I don't think the windows task manager is the
best tool to work on memory problems with.  I use Yourkit but if you
want a free tool, use http://www.eclipse.org/mat/ - at least I've seen
some users have success with that in the past.

> At the worst case, I'm thinking of having a timer thread that periodically
> does System.gc() every time the free memory falls below a certain
> percentage.

Do you see an out of memory problem?  I'm not sure why you want to
force the heap down?  Weaving is not free and so consumes some amount
of memory.  Weaving is faster if it can utilise more memory to do its
work.  The important thing is that care is taken not to anchor that
memory such that it cannot be cleared up later.  AspectJ uses weak
references for anything that can be collected later.  (It used to use
soft references but I've yet to see a VM that treated them properly).
Weak references mean the garbage will be collected a little while
after weaving is complete.

> Please help me out as such a memory performance will be a show stopper if
> there is no way around!

I don't quite understand why it is a show stopper if you don't have an
out of memory problem?  Give the VM less memory if you don't want
AspectJ to use it...

Having said all that, there are 2 things that will effect the ongoing
size of a world/weaver (and there is one world/weaver per
classloader).  That is the number of aspects you have and the number
of types that are  affected by ITDs.  Types representing aspects and
types affected by ITDs are held onto longer than I would like right
now.  However, you will only see the affect of this by forcing a few
GCs then observing the size of the AspectJ World objects - are they
particularly large?

Simone mentioned cflow pointcuts, you didn't say whether you had any
of those?  If you do you should try using the aspectjrt.jar in this
bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=251019 - I would
like to commit that change but no-one has yet confirmed to me that the
fix addresses the problem.

If you want to work further on this, you should open a bugzilla and
attach some heap reports so I can check the memory in detail.

cheers
Andy

On 14 May 2010 04:06, Ashank <k_arvind_shankar@xxxxxxxxx> wrote:
>
> Hello Andy,
>
> My AspectJ version is 1.6.8 and sun JDK version is 1.6.0_07
>
> Hello Simone,
>
> Thank you very much for the helpful explanations, especially regarding
> memory usage of AspectJ components. I am indeed using LTW using the agent.
> My web application without AspectJ used to always 'stabilize' at 150 to 250
> MB tops (values as seen from windows task manager). With AspectJ and my
> aspects it gets to 750 - 800MB within 2 minutes of browsing. If I don't
> browse in my webapp, the memory consumed barely increases since start, at
> least not at the rate when I do browse (suggesting that the jsp pages
> browsed are being woven after compilation).
>
>> " You could try performing compile time weaving,...."
> Since I want my dynamic JSP classes to be weaved, I don't think I can use
> compile time weaving unless I'm missing something in which case please point
> out.
>
> Regarding JoinPoint class usage, For the most part, I almost always used the
> JoinPointStaticPart class.
>
> The redeploy issue was also interesting although as you correctly mentioned,
> my webapp is not being redeployed when its already up. I do have two almost
> identical web apps that get loaded together though. I am mainly using only
> one of them.
>
> In my pointcuts, I almost always use a within() and execution() combination
> to identify method calls. I even disabled the one pointcut where I didn't
> use a within and the memory issue was still there.
>
> At the worst case, I'm thinking of having a timer thread that periodically
> does System.gc() every time the free memory falls below a certain
> percentage.
>
> Is there anything informative in the heap dump? Please help! Thanks again!
>
> -Arvind
> --
> View this message in context: http://aspectj.2085585.n4.nabble.com/please-help-heap-space-ballooning-when-I-use-aspectJ-with-my-webapplication-tp2197371p2216414.html
> Sent from the AspectJ - users mailing list archive at Nabble.com.
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>