Hi Nuno,

Make sure you are on a recent AspectJ. You could also try turning on type
demotion - it is a -Xset option, don't quite recall how to turn those on
via maven (-Xset:typeDemotion=true). Type demotion tries to run with a
smaller footprint by throwing things away more eagerly. If it needs them
again later it pulls them back in. I thought it was on by default but very
quickly browsing the code it seems to be only automatically on for load
time weaving or when using it in an IDE environment.

​Normally I'd say the use of wildcards is more likely to impact compilation
time than memory usage, however depending on how your pointcut is written
AspectJ may need to chase down supertypes and interfaces to determine a
match. The more of those that need to get chased down the more memory is
likely to be used.  In these situations using wildcards would save a little
memory because we can tell immediately that * matches something without
needing to look at the supertypes of the potential match.  Are you using
declaring type patterns in your pointcut (execution(* Foo.*(..))) or not
(execution(* *(..)) - the former is what may need more chasing/loading of
types (having to dig into whether a target is a subtype of Foo).   Are you
using execution() or using call(), the former is likely to be a bit
cheaper. If you can add a scope to your pointcut, do so (i.e. a within
clause).

cheers,
Andy

On 15 June 2016 at 10:26, Nuno GASPAR (contractor) <nuno.gas...@amadeus.com>
wrote:

> Hello.
>
>
> I'm using AspectJ in a rather big project, and I'm getting an
> OutOfMemoryException during the compilation process. I only have one aspect
> defined, with only one pointcut, and some regular logging code on before()
> and after() advices.
>
>
> This is a recurrent question, but so far I've only seen people
> recommending increasing the maximum amount of allocated memory through the
> -Xmx parameter.  Indeed, this did solve my problem, but this is not really
> a good solution, since this code needs to be built by a software factory
> that may be performing other (compilation) tasks at the same time...
>
>
> I would like to know if there are any tips you can give me on how to lower
> the amount of memory needed by aspectj?
>
>
> I read that using incremental compilation can consume more memory, but
> indeed I'm not using it --- well, at least I do not have the option
> specified in my pom.xml. Maybe I should explicitly include
>
> <useIncrementalCompilation>false</useIncrementalCompilation> ?
>
>
> I also guess that the way a pointcut is specified matters, that is, if
> using regular expressions * or .. may require more memory?
>
>
> Any general tips you might have based on your past experiences?
>
>
> Best regards,
>
> Nuno
>
>
>
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@eclipse.org
> To change your delivery options, retrieve your password, or unsubscribe
> from this list, visit
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
_______________________________________________
aspectj-users mailing list
aspectj-users@eclipse.org
To change your delivery options, retrieve your password, or unsubscribe from 
this list, visit
https://dev.eclipse.org/mailman/listinfo/aspectj-users

Reply via email to