Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] aspectj configuration question

I would not actually recommend the second approach and I'm not even
sure it would work.  What I was suggesting was to separate each aspect
and each service class into its own project/jar and so each aspect
would only be woven with the appropriate service class.  However, this
would not work with LTW since all classes would be visible to all
aspects.

The memory consumption pattern you are seeing does sound too high.
There are two experimental options you could try that may address
memory consumption.  You can read more here:
http://andrewclement.blogspot.com/2010/07/ajdt-memory-usage-reduction.html
(although I am not sure if this is available for LTW, maybe only
compile time weaving).

Another thing I'd recommend is that if at all possible, switch to
compile time weaving.  This will save some significant memory at run
time.

Let me know if this helps.  If not, perhaps we can have a look at your
heap to see if there is anything obvious that we can do.

On Thu, Oct 21, 2010 at 8:00 AM, yohan chandra <yohan.chandra@xxxxxxxxx> wrote:
> Hi Andrew,
>
> Thanks for the answer. I actually have applied the 1st approach, the
> pointcuts and advices defined in aspectA are applied to serviceA only and
> it's working well. However the issue is with memory I believe even though
> only specific pointcut is applied, the class has been woven by other
> unrelated aspects and this consumes memory. I monitored my app and I noticed
> a large increase of memory usage since AspectJ got implemented. I took the
> heap dump and significant portion of it are AspectJ related instances.
>
> My app has lots of aspects and lots of "include within" classes. As I watch
> from the log, each of this "include within" class is woven with number of
> aspects that I have, even though only specific aspect will be applied later
> by the pointcut. Suppose If i have 20 aspects and 30 "include within"
> classes the total number will be 600. I am trying to reduce the memory usage
> of my AspectJ implementation as much as i can so it can go into production
> but currently I am blocked.
>
> Could you elaborate on the 2nd approach? I am trying to weave only specific
> aspect to its specific class(es).
>
> Regards,
> - Yohan chandra -
>
> On Wed, Oct 20, 2010 at 5:36 PM, Andrew Eisenberg <andrew@xxxxxxxxxxxx>
> wrote:
>>
>> > 1. Will servicesA be woven with all the three aspects (aspectA,B,C)?
>> Correct.
>>
>> > 2. If Yes, is there any way to configure specific aspect to weave only
>> > specific class(es), example: AspectA weaves only servicesA?
>>
>> Not directly, but there are two suggestions:
>>
>> 1. Within each specific aspect, you can add a within() pointcut to
>> each of your advice declarations and this will ensure that AspectA is
>> only applied to ServiceA.  Eg, something like this:
>>
>> pointcut canApplyTo() : within(ServiceA);
>>
>> after() : doingSomethingAwesome() && canApplyTo() {
>>   ...
>> }
>>
>> 2. Separate each of your service and aspects into separate modules to
>> pair serviceA and aspectA, etc.
>>
>> I'd strongly recommend #1.
>> _______________________________________________
>> aspectj-users mailing list
>> aspectj-users@xxxxxxxxxxx
>> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
>


Back to the top