Bug 41049 - java.lang.OutOfMemoryError in <for> <from antcall>
Summary: java.lang.OutOfMemoryError in <for> <from antcall>
Status: RESOLVED FIXED
Alias: None
Product: Ant
Classification: Unclassified
Component: Core (show other bugs)
Version: 1.7.0Beta3
Hardware: Sun Windows XP
: P2 normal (vote)
Target Milestone: ---
Assignee: Ant Notifications List
URL:
Keywords: JDK1.4
Depends on:
Blocks:
 
Reported: 2006-11-27 13:47 UTC by Bob Niedbalski
Modified: 2008-02-22 12:18 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Bob Niedbalski 2006-11-27 13:47:01 UTC
For apache-ant-1.7.0Beta3 and ant-contrib-1.0b3
ant run-dummy causes OutOfMemoryError where:

   <target name="run-dummy" >
      <for param="i" begin="1" end="5000000">
        <sequential>
          <echo message="i is @{i}" />
          <antcall target="dummy" />
        </sequential>
      </for>
   </target>

   <target name="dummy" >
      <for param="j" begin="1" end="50">
        <sequential>
          <echo message="   j is @{j}" />
        </sequential>
      </for>
   </target>

Will only run i < 400.
Tried <macrodef>, the memory leak is less, but is still there:

   <target name="run-dummyalt" >
      <for param="i" begin="1" end="5000000">
        <sequential>
          <echo message="i is @{i}" />
          <dummyalt/>
        </sequential>
      </for>
   </target>

   <macrodef name="dummyalt">
      <sequential>
      <for param="j" begin="1" end="50">
        <sequential>
          <echo message="   j is @{j}" />
        </sequential>
      </for>
      </sequential>
   </macrodef>
Comment 1 Matt Benson 2006-11-27 14:36:38 UTC
Is this a regression?  i.e., does it work in Ant 1.6.5?
Comment 2 Peter Reilly 2006-11-27 14:39:14 UTC
It has actually being fixed in ant 1.7.0rc1.
Comment 3 Bob Niedbalski 2006-11-28 14:51:56 UTC
Yes, the memory leak is essentially fixed in apache-ant-1.7.0RC1.
Yet there is still an extremely small leak.  You have to let 'run-dummy' a long 
time (30 min.+) to notice it.
There is also a memory leak with the <macrodef> version of the test task 'run-
dummyalt' (BTW 'run-dummyalt' runs a lot faster than the 'run-dummy' 
<target><antcall> version):

   <target name="run-dummyalt" >
      <for param="i" begin="1" end="5000000">
        <sequential>
          <echo message="i is @{i}" />
          <dummyalt/>
        </sequential>
      </for>
   </target>

   <macrodef name="dummyalt">
      <sequential>
      <for param="j" begin="1" end="50">
        <sequential>
          <echo message="   j is @{j}" />
        </sequential>
      </for>
      </sequential>
   </macrodef>
Comment 4 Bob Niedbalski 2006-11-28 16:42:20 UTC
ant run-dummyalt fails:
     [echo] i is 21706
     [echo]    j is 1
[...]
     [echo]    j is 40

BUILD FAILED
[...]
C:\Users\Bob\work\_LOF_QA\Nialls\newProject\LPTRunner\build.xml:279: 
java.lang.OutOfMemoryError
Comment 5 Peter Reilly 2006-11-29 06:42:55 UTC
Thanks for the information and the test file.
I have found the source the the leakage.
ComponentHelper attempts to keep track
of all created tasks and invalidate the
task instance if the task definition changes.

With changes in the way ant works in ant 1.6 and ant 1.7
from ant 1.5, I do not think that ComponentHelper
needs to keep track of the tasks.

Comment 6 Peter Reilly 2006-12-10 14:26:34 UTC
I have commmitted the change to ComponentHelper.
You should be able to test with the next nightly
build or with ant 1.7.0RC2.