Newsletter sign-up
View all newsletters

Sign up for our technology specific newsletters.

Enterprise Java
Email Address:
JavaWorld Daily Brew

AspectJ-1.6.3rc1 getting java.lang.OutOfMemoryError: Java heap space


Hi,
I am using AspectJ 1.6.3rc1 for Aspect Oriented Programming. I have created an aspect as following:

package com.aspect;

import com.db.DBConnection;

public aspect MyAspect {
pointcut threadCreation(DBConnection conn) : call(* com.app..ResourceServiceImpl.uploadNormalContent*(..)) && (cflow(call(void com.db.DBConnection.close()))) && target(conn);
void around(DBConnection conn) : threadCreation(conn) {
System.out.println("Got Connection:" + conn);
proceed(conn);
}
}

I have my application code having approximately 1063 java files. I am using the following aspect command to compile my aspect program:

ajc -sourceroots C:\npg_ws_aspect\nated -outjar C:\npg_ws_aspect\npg.jar -1.6 -classpath "C:\npg_ws_aspect\nated\WEB-INF\lib\captcha.jar;C:\npg_ws_aspect\nated\WEB-INF\lib\commons-beanutils-1.7.0.jar;C:\npg_ws_aspect\nated\WEB-INF\lib\commons-codec-1.3.jar;C:\npg_ws_aspect\nated\WEB-INF\lib\commons-collections-3.1.jar;C:\npg_ws_aspect\nated\WEB-INF\lib\commons-digester-1.8.jar;C:\npg_ws_aspect\nated\WEB-INF\lib\commons-httpclient-3.0.jar;C:\npg_ws_aspect\nated\WEB-INF\lib\commons-logging-api-1.1.jar;C:\npg_ws_aspect\nated\WEB-INF\lib\contact-importer.jar;C:\npg_ws_aspect\nated\WEB-INF\lib\cos.jar;C:\npg_ws_aspect\nated\WEB-INF\lib\dom4j-1.5.jar;C:\npg_ws_aspect\nated\WEB-INF\lib\ehcache-1.1.jar;C:\npg_ws_aspect\nated\WEB-INF\lib\imaging.jar;C:\npg_ws_aspect\nated\WEB-INF\lib\ip2location.jar;C:\npg_ws_aspect\nated\WEB-INF\lib\iText-2.1.2u.jar;C:\npg_ws_aspect\nated\WEB-INF\lib\jaxrpc.jar;C:\npg_ws_aspect\nated\WEB-INF\lib\jldap-4.3.jar;C:\npg_ws_aspect\nated\WEB-INF\lib\json.jar;C:\npg_ws_aspect\nated\WEB-INF\lib\jsonrpc.jar;C:\npg_ws_aspect\nated\WEB-INF\lib\jsse.jar;C:\npg_ws_aspect\nated\WEB-INF\lib\jstl.jar;C:\npg_ws_aspect\nated\WEB-INF\lib\ldapjdk.jar;C:\npg_ws_aspect\nated\WEB-INF\lib\libidn-1.0.jar;C:\npg_ws_aspect\nated\WEB-INF\lib\log4j-1.2.14.jar;C:\npg_ws_aspect\nated\WEB-INF\lib\lucene-core-2.3.0.jar;C:\npg_ws_aspect\nated\WEB-INF\lib\lucene-demos-2.3.0.jar;C:\npg_ws_aspect\nated\WEB-INF\lib\mail.jar;C:\npg_ws_aspect\nated\WEB-INF\lib\memcached_client.jar;C:\npg_ws_aspect\nated\WEB-INF\lib\not-yet-commons-ssl-0.3.7.jar;C:\npg_ws_aspect\nated\WEB-INF\lib\PDFBox-0.7.0.jar;C:\npg_ws_aspect\nated\WEB-INF\lib\poi-3.0-rc4-20070503.jar;C:\npg_ws_aspect\nated\WEB-INF\lib\poi-contrib-3.0-rc4-20070503.jar;C:\npg_ws_aspect\nated\WEB-INF\lib\poi-scratchpad-3.0-rc4-20070503.jar;C:\npg_ws_aspect\nated\WEB-INF\lib\standard.jar;C:\npg_ws_aspect\nated\WEB-INF\lib\tiles-api-2.0.5.jar;C:\npg_ws_aspect\nated\WEB-INF\lib\tiles-core-2.0.5.jar;C:\npg_ws_aspect\nated\WEB-INF\lib\tiles-jsp-2.0.5.jar;C:\npg_ws_aspect\nated\WEB-INF\lib\tm-extractors-0.4.jar;C:\npg_ws_aspect\nated\WEB-INF\lib\xcc.jar;C:\npg_ws_aspect\nated\WEB-INF\lib\xerces.jar;C:\npg_ws_aspect\nated\WEB-INF\lib\XPAAJ.jar;C:\npg_ws_aspect\nated\WEB-INF\lib\xparser.jar;C:\npg_ws_aspect\nated\WEB-INF\lib\zimbra-charset.jar;C:\npg_ws_aspect\nated\WEB-INF\lib\zimbracommon.jar;C:\npg_ws_aspect\nated\WEB-INF\lib\zimbraim.jar;C:\npg_ws_aspect\nated\WEB-INF\lib\zimbra-native.jar;C:\npg_ws_aspect\nated\WEB-INF\lib\zimbrastore.jar;C:\apache-tomcat-5.5.26\common\lib\commons-el.jar;C:\apache-tomcat-5.5.26\common\lib\jasper-compiler.jar;C:\apache-tomcat-5.5.26\common\lib\jasper-compiler-jdt.jar;C:\apache-tomcat-5.5.26\common\lib\jasper-runtime.jar;C:\apache-tomcat-5.5.26\common\lib\jsp-api.jar;C:\apache-tomcat-5.5.26\common\lib\mysql-connector-java-5.0.5-bin.jar;C:\apache-tomcat-5.5.26\common\lib\naming-factory.jar;C:\apache-tomcat-5.5.26\common\lib\naming-factory-dbcp.jar;C:\apache-tomcat-5.5.26\common\lib\naming-resources.jar;C:\apache-tomcat-5.5.26\common\lib\servlet-api.jarC:\aspectj1.6\lib\aspectjrt.jar;C:\aspectj1.6\lib\aspectjtools.jar;C:\aspectj1.6\lib\aspectjweaver.jar;C:\aspectj1.6\lib\org.aspectj.matcher.jar;C:\apache-tomcat-5.5.26\common\lib\servlet-api.jar;C:\npg_ws_aspect\nated\WEB-INF\lib\ant.jar;C:\npg_ws_aspect\nated\WEB-INF\lib\ant-launcher.jar"

When I am executing this command I am getting the following exception:

C:\npg_ws_aspect\nated\src\com\nated\app\resource\dao\impl\ResourceDAOImpl.java
[error] Internal compiler error
java.lang.OutOfMemoryError: Java heap space
at java.util.Arrays.copyOf(Arrays.java:2786)
at java.io.ByteArrayOutputStream.write(ByteArrayOutputStream.java:94)
at java.io.PrintStream.write(PrintStream.java:430)
at sun.nio.cs.StreamEncoder.writeBytes(StreamEncoder.java:202)
at sun.nio.cs.StreamEncoder.implFlushBuffer(StreamEncoder.java:272)
at sun.nio.cs.StreamEncoder.flushBuffer(StreamEncoder.java:85)
at java.io.OutputStreamWriter.flushBuffer(OutputStreamWriter.java:168)
at java.io.PrintStream.write(PrintStream.java:477)
at java.io.PrintStream.print(PrintStream.java:619)
at org.aspectj.weaver.bcel.LazyMethodGen$BodyPrinter.pad(LazyMethodGen.j
ava:773)
at org.aspectj.weaver.bcel.LazyMethodGen$BodyPrinter.printLabel(LazyMeth
odGen.java:709)
at org.aspectj.weaver.bcel.LazyMethodGen$BodyPrinter.printInstruction(La
zyMethodGen.java:720)
at org.aspectj.weaver.bcel.LazyMethodGen$BodyPrinter.print(LazyMethodGen
.java:670)
at org.aspectj.weaver.bcel.LazyMethodGen$BodyPrinter.run(LazyMethodGen.j
ava:598)
at org.aspectj.weaver.bcel.LazyMethodGen.print(LazyMethodGen.java:559)
at org.aspectj.weaver.bcel.LazyClassGen.printOne(LazyClassGen.java:754)
at org.aspectj.weaver.bcel.LazyClassGen.print(LazyClassGen.java:716)
at org.aspectj.weaver.bcel.LazyClassGen.toLongString(LazyClassGen.java:7
04)
at org.aspectj.weaver.bcel.BcelWeaver.weave(BcelWeaver.java:1762)
at org.aspectj.weaver.bcel.BcelWeaver.weaveWithoutDump(BcelWeaver.java:1
700)
at org.aspectj.weaver.bcel.BcelWeaver.weaveAndNotify(BcelWeaver.java:146
6)
at org.aspectj.weaver.bcel.BcelWeaver.weave(BcelWeaver.java:1273)
at org.aspectj.ajdt.internal.compiler.AjPipeliningCompilerAdapter.weaveQ
ueuedEntries(AjPipeliningCompilerAdapter.java:435)
at org.aspectj.ajdt.internal.compiler.AjPipeliningCompilerAdapter.queueF
orWeaving(AjPipeliningCompilerAdapter.java:371)
at org.aspectj.ajdt.internal.compiler.AjPipeliningCompilerAdapter.afterP
rocessing(AjPipeliningCompilerAdapter.java:358)
at org.aspectj.ajdt.internal.compiler.CompilerAdapter.ajc$after$org_aspe
ctj_ajdt_internal_compiler_CompilerAdapter$5$6b855184(CompilerAdapter.aj:98)
at org.aspectj.org.eclipse.jdt.internal.compiler.Compiler.process(Compil
er.java:652)
at org.aspectj.org.eclipse.jdt.internal.compiler.Compiler.compile(Compil
er.java:392)
at org.aspectj.ajdt.internal.core.builder.AjBuildManager.performCompilat
ion(AjBuildManager.java:975)
at org.aspectj.ajdt.internal.core.builder.AjBuildManager.performBuild(Aj
BuildManager.java:265)
at org.aspectj.ajdt.internal.core.builder.AjBuildManager.batchBuild(AjBu
ildManager.java:179)
at org.aspectj.ajdt.ajc.AjdtCommand.doCommand(AjdtCommand.java:112)

(no source information available)
ABORT

Exception thrown from AspectJ 1.6.3rc1

This might be logged as a bug already -- find current bugs at
http://bugs.eclipse.org/bugs/buglist.cgi?product=AspectJ&component=Compi...

Bugs for exceptions thrown have titles File:line from the top stack,
e.g., "SomeFile.java:243"

If you don't find the exception below in a bug, please add a new bug
at http://bugs.eclipse.org/bugs/enter_bug.cgi?product=AspectJ
To make the bug a priority, please include a test program
that can reproduce this exception.
Java heap space

when weaving classes
when weaving
when batch building BuildConfig[null] #Files=1063
Java heap space

Does anybody have any idea on how much memory is required for performing this activity? Is there anything I am doing wrong? I am stuck with this problem for 2 days and not able to understand what to do next. Any kind of hint or information will be very helpful for me.

Thanks in advance for your time.

Thanks & Regards,

Raj Kumar

Your rating: None Average: 4 (1 vote)

Hello Raj, You should edit

Hello Raj,

You should edit the ajc.bat file in the /bin folder and modify the Xmx setting. I think the default is quite low (might be 64m). I would put it up to 512m or 768m perhaps.

cheers,
Andy.

Thanks, Problem is Solved

Hi Andy,
Thanks a lot for your time and help.
I followed your suggestion and used 768m as Xmx setting and it worked without any problem. Now I am able to do the required build successfully.
Thanks again. You are great. :)

Thanks & Regards,
Raj Kumar

Thanks for sharing. Writing

Thanks for sharing.
Writing | Essay Writing | Research Paper

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <p> <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <br /> <br> <strike>
  • Lines and paragraphs break automatically.
  • Use <!--pagebreak--> to create page breaks.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.

More information about formatting options

CAPTCHA
Just checking to see if you're an actual person rather than a spammer. Sorry for the inconvenience.