Ron Bodkin had been working on reducing the memory usage of AspectJ LTW. He had released an experimental version of aspectjweaver.jar. I ran my tests on it today and the results are very encouraging – the memory consumed does not depend on the number of classes loaded.
Ron told me in private email communication that he is working with Andy Clement to get his changed into AspectJ mainline; I hope we can see Rons fixes soon in AspectJ official release.
I wrote some tests to measure the memory overhead of load-time weaving in AspectJ and AspectWerk. My tests show that the memory required for LTW increases almost linearly for the number of classes loaded (click on the image for a larger version).
The following tests were run:
- Baseline with no AOP tool involved (Plain)
- AspectWerk LTW, with no classes weaved (AW No Weave)
- AspectJ LTW, with no classes weaved (AJ No Weave)
- AspectWerkz LTW, with all classes weaved(AW Weave All)
- AspectJ LTW, with all classes weaved (AJ Weave All)
An interesting observation that can be made from the chart above is that AspectWerkz adds a significant overhead irrespective of whether one uses weaving or not – AspectJ does not seem to have this problem.
AspectJ 1.5.0 and AspectWerkz 2.0 versions were used, and all tests were run on Apple JVM 1.5.0_05.
Two other tests I am planning to run are:
- Test to compare the effect of number of pointcuts matched on the memory overhead
- Test to compare the effect of number of classloaders involved
PS: Ron Bodkin mentioned an experimental low-memory-overhead build of AspectJ in one of his blog posts, but I can't find the file anywhere on WWW. Once I have located it, I will run the tests on that build and publish the results.