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>
Is this a regression? i.e., does it work in Ant 1.6.5?
It has actually being fixed in ant 1.7.0rc1.
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>
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
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.
I have commmitted the change to ComponentHelper. You should be able to test with the next nightly build or with ant 1.7.0RC2.