ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dominique Devienne <DDevie...@lgc.com>
Subject RE: OutOfMemoryException on large build
Date Fri, 20 Feb 2004 22:25:54 GMT
> From: Jeremy Haile [mailto:jhaile@fastmail.fm]
> 
> We have a fairly long build process.  Currently our project consists of
> many modules, each with their own build.xml file.  There is also a master
> build.xml file that calls each module build.xml sequentially (in order of
> module dependencies).
> 
> A typical module target in the master build.xml looks like:
> 
> <target name="event_mgmt" description="Event management" depends="sysmgr"
> >
>         <echo message="Building Event Management module" />
>         <ant dir="${src.dir}/event_mgmt"
>                 target="${target}" inheritAll="false" />
> </target>
> 
> The module build.xml files perform many tasks from compiling classes,
> running xdoclet tasks, archiving ejb-jars and libs, JBoss SARs, signing
> jars etc. etc.  A complete build process starting with a "clean" takes
> around 6-7 minutes typically.  After adding a new module recently, I am
> receiving an OutOfMemoryError.  However, it does not seem to be specific
> to that module as other people have received it in the past and the OOME
> occurs during different tasks if I play around with the build process.
> 
> What I find very strange is that if I watch Ant's memory usage (using
> system monitor or top) it constantly increases during the entire build.
> It typically starts around 150 MB and increases to around 330MB before
> the OOME.  The OOME always occurs towards the later part of the build
> process. Why would ant not be releasing memory through garbage collection
> after each module is compiled?  When I watch the memory usage it is
> always increasing, never decreasing as I would expect.
> 
> My computer has 1 Gig of RAM and is an Intel P4 2+ Ghz Dell PC.
> 
> I have tried increasing the heap size and stack size using the Xmx and
> Xss flags in ANT_OPTS to no avail.  Any help or ideas would be greatly
> appreciated.

Well, the JVM is not required to always free out-of-reach objects, but it is
OTOH before sending an OOME though.

The two main things that improve memory usage:
1) Fork some tasks, like <java>, <junit>, <javac>. The memory is used in
another VM, and released when the process exists.
2) Use a JDK whose Javac actually releases memory... The first know to do
that is JDK 1.4.2 AFAIK.

Always forking <javac> (as in (1)) helps quite a bit.

Also, different versions of Ant hold on to more or less objects. I saw a few
fixes the past weeks regarding avoiding holding on to references too long,
to avoid memory leaks. Try a recent version of Ant maybe (1.6.1). --DD

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message