OutofMemory during compilation

  • Thread starter OccasionalFlyer
  • Start date
O

OccasionalFlyer

I have been building an application using ant on jdk 1.4.2 for about
2.5 years. No problem. Today I'm getting the error during compilation

[javac] java.lang.OutOfMemoryError


I compiled just yesterday afternoon and did not get this error.
Here's what I did differently.
1. The application requires several jar files that it takes from a
repository.
2. Two of the jar files it needs, however, go into a lib directory of
the web app I'm trying to build.
3. I modified a properties file so that the application would get the
two jars from the same repository as everything else. Then, I'm simply
doing ant clean compile war

This shows me messages that jar files, including the two problem
jar files, are fetched. However, the jar file that has the first
problem during compilation is 47K in the repository but only about 900
bytes in the lib directory of the application.

Examining the memory of the Linux server that the compile is
running on, there appears to be nothing significant using memory, and
as I said, I've been able to do the same compilation for over two years
without a problem. What might be going on? It's not just an issue of
using compiler flags for more memory (and exactly how to pass those to
the ant command I haven't figured out). Any suggestions? We're all
stuck on this.=20

The error happens during the compile step:
<target name=3D"compile" depends=3D"init">
<mkdir dir=3D"${build.dir}/classes"/>
<javac srcdir=3D"${src.dir}"
destdir=3D"${build.dir}/classes"
debug=3D"${compile.debug}"
deprecation=3D"${compile.deprecation}"
optimize=3D"${compile.optimize}">
<classpath refid=3D"project.classpath"/>
</javac>
</target>
The compile output identifies the "optimize" line as where the error is
but I assume that this is just the end of the compile command. =20

Does anyone have a suggestion for what I might try to figure out how
to resolve or figure out this sudden, new problem on a process that has
been working fine?=20

Also, if I wanted to try to specify more memory during the compile,
though I'm doubtful it will, help, how would I specify that for ant? I
know how to do it for a straightforward compile with javac. Thanks.
 
S

Steve W. Jackson

"OccasionalFlyer said:
I have been building an application using ant on jdk 1.4.2 for about
2.5 years. No problem. Today I'm getting the error during compilation

[javac] java.lang.OutOfMemoryError

[ snip ]

The "javac" command has a heap like anything Java. I've encountered
this recently too. The simple solution is to modify the "javac" task in
your Ant build file so that it includes maximumMemorySize="?" to use a
larger than default heap. I set mine at 256m, though that probably was
larger than I required.

= Steve =
 
O

OccasionalFlyer

Steve said:
OccasionalFlyer said:
I have been building an application using ant on jdk 1.4.2 for about
2.5 years. No problem. Today I'm getting the error during compilation

[javac] java.lang.OutOfMemoryError

[ snip ]

The "javac" command has a heap like anything Java. I've encountered
this recently too. The simple solution is to modify the "javac" task in
your Ant build file so that it includes maximumMemorySize="?" to use a
larger than default heap. I set mine at 256m, though that probably was
larger than I required.

= Steve =

Thanks Steve, but I'm having trouble figuring out how to get ant to use
the larger heap size. I tried
fork="true"
memoryinitialsize="512m"

I tried just the second and ant said it would not use that without fork
set to true. So I set fork to true and ant said the options were
incompatible. Anyway, I havent' found a way to increase the heap size.

Ken
 
S

Steve W. Jackson

"OccasionalFlyer said:
Steve said:
OccasionalFlyer said:
I have been building an application using ant on jdk 1.4.2 for about
2.5 years. No problem. Today I'm getting the error during compilation

[javac] java.lang.OutOfMemoryError

[ snip ]

The "javac" command has a heap like anything Java. I've encountered
this recently too. The simple solution is to modify the "javac" task in
your Ant build file so that it includes maximumMemorySize="?" to use a
larger than default heap. I set mine at 256m, though that probably was
larger than I required.

= Steve =

Thanks Steve, but I'm having trouble figuring out how to get ant to use
the larger heap size. I tried
fork="true"
memoryinitialsize="512m"

I tried just the second and ant said it would not use that without fork
set to true. So I set fork to true and ant said the options were
incompatible. Anyway, I havent' found a way to increase the heap size.

Ken

Well...my Ant build file has only one javac task in it. And the task
looks pretty much like this:

<javac srcdir="${src}" destdir="${dest}"
deprecation="on" fork="true" memoryMaximumSize="256m">
<compilerArg value="-Xlint:unchecked"/>
</javac>

That's not exact, as I've also got classpath and extdirs and a couple
other things. But that's the gist of it. And it resolved my out of
memory error on compiling.

You'll find that "memoryinitialsize" is incorrect -- it should be
"memoryInitialSize" instead, as case matters. Personally, I would
suggest using the max, though, rather than initial size.

= Steve =
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,067
Latest member
HunterTere

Latest Threads

Top