Bug 24448 - Ant causing Out of Memory
Summary: Ant causing Out of Memory
Status: RESOLVED WONTFIX
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Ant (show other bugs)
Version: 2.0   Edit
Hardware: PC other
: P2 normal with 3 votes (vote)
Target Milestone: 2.1 RC2   Edit
Assignee: Platform-Ant-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: core, performance, ui
: 29421 29961 32336 33391 33906 35503 35751 35864 36048 36072 36639 36678 36781 36812 36827 37616 37912 38338 38990 39118 40250 41646 45424 45889 45948 46218 46790 53318 58075 62489 86523 (view as bug list)
Depends on:
Blocks:
 
Reported: 2002-10-07 09:32 EDT by Darin Swanson CLA
Modified: 2006-02-03 12:03 EST (History)
37 users (show)

See Also:


Attachments
buildfile that leaks 20000k (10.06 KB, text/xml)
2002-10-11 09:41 EDT, Derek Karnes CLA
no flags Details
AntCorePlugin (5.90 KB, text/plain)
2003-02-07 12:09 EST, ulrich köster CLA
no flags Details
"kit" to produce patched Ant 1.5.1 for ProcessDestroyer (4.72 KB, application/x-zip-compressed)
2003-02-26 11:01 EST, Jim Allers CLA
no flags Details
Dump of AntClassLoader object (355.70 KB, text/html)
2006-02-03 11:38 EST, Mark Melvin CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Darin Swanson CLA 2002-10-07 09:32:32 EDT
From the ant-dev@jakarta.apache.org:

>>While playing with Eclipse 2.0.1 IDE and ant 1.5 plugin, I noticed
>>that Eclipse (or ant) didn't release memory used.

>>And after 10 to 20 use of ant, the IDE shutdown itself.
Comment 1 Derek Karnes CLA 2002-10-11 09:41:27 EDT
Created attachment 2168 [details]
buildfile that leaks 20000k
Comment 2 Derek Karnes CLA 2002-10-11 09:42:24 EDT
Running the attached buildfile leaves the eclipse java process about 20000k 
larger than before the build (according to windows' unreliable task manager). 
It only takes me 3 or 4 runs to either get an out of memory error (and it is 
NOT pretty when Eclipse runs out of memory saving your workspace!) or for the 
process to simply exit (presumably out of memory). My source is 1600+ files, 
but the javac is forked so that shouldn't matter too much.
Comment 3 Craig Goss CLA 2002-10-11 16:49:12 EDT
I'm going to second this one.  I'm also using "-vmargs -Xmx256M" on a machine 
with 1G of memory and I periodically run out of memory at which point Eclipse 
2.0.1 unceremoniously shuts down.  For a long time I didn't know what was 
causing the problem, but over time I have come to believe that Ant is 
involved.  If I use the project build, the problem never seems to surface; if 
I use Ant (which I'm doing more frequently these days), it shows up regularly.

For the record, I'm also using the AntView plugin but don't believe it is 
responsible as I have seen the same problem using Eclipse Ant.  My Ant version 
is 1.5 if it makes any difference.
Comment 4 Darin Swanson CLA 2002-10-14 15:52:50 EDT
I have done some looking for leaks on the 2.1 code base and I am not seeing 
much.  Would either of you be able to check out the integration/M2 builds that 
come out this week and report back?
Comment 5 Derek Karnes CLA 2002-10-22 13:03:09 EDT
Using the link Darin sent me for the M2 build (Build ID 200210181211) I was 
able to successfully compile a dozen times. The Windows task manager showed 
memory getting reclaimed occasionally; the most eclipse went up to was 99k; it 
generally wavered between 28k and 40k. In the previous build I never saw any 
evidence of garbage collection kick in. I'm betting this one is OBE.
Comment 6 Darin Swanson CLA 2002-11-12 22:14:37 EST
Moving to M4...good to keep checking.
Comment 7 Darin Swanson CLA 2002-12-24 11:33:35 EST
From the newsgroup (david_lee@ulstek.com.tw)
> To start with, I am using the M4 build. Java VM is j2sdk1.4.1_01.
> 
> What my project does is to build ejb 1.1 files using the XDoclet API and
> Ant.
> 
> As for the bug report, I have found that it has already been filed at
> Bugzilla Bug 24448.
> 
> Previously, with the 1.3.1 vm, the ide freezes after 15 to 20 builds. Now
> with the 1.4 vm, the ide runs out of memory at 40 to 50 builds. I am also
> enclosing a doc file with the messages that I am seeing.
> 
> For reproducing the test case, I would recommend downloading the Lomboz
> Eclipse plug-in, create a J2EE project and an ejb container. What the
> plug-in does is just to help in writing the XDoclet - Ant xml files. Then
> execute the "Generate EJB classes" function repeatedly or write a simple
> build.xml file which calls the Lomboz generated Ant scripts and execute it
> using the built in ant task. The results would be the same ..... Out of
> Memory Error.
Comment 8 Archimedes Trajano CLA 2003-01-02 00:26:06 EST
I seem to be getting the same error with 2.1 M4
Comment 9 l3.zL CLA 2003-01-15 08:56:47 EST
Does anyone know if this memory leak has been addressed in the 2.2 version??
If so, I can download it even before the M1 release, because it's quite 
annoying ANT-ing from within a Command Prompt.

Thx.
Comment 10 Charles Hasegawa CLA 2003-02-05 12:41:48 EST
I can vouch that this bug is still present in the 200212181304 build (M4 build).
I have noticed this issue through any number of build files, even for simple 
tasks.

I run on Win2k with Eclipse args of : -vmargs -Xmx256M
My machine has 512MB of memory and with the task manager going, I generally die 
when Eclipse hits 185MB+
Comment 11 Charles Hasegawa CLA 2003-02-05 16:07:05 EST
I noticed something today - when running ANT over and over, I steady consumed 
more memory. At one point I was up to about 120MB. About 5 minutes later I was 
ready to run ANT again, and happily noticed I had shot down to only 51MB (I 
figure some sort of GC had happened). When I ran ANT, the memory usage shot 
immediately back up to around 145MB (which is about where it would have been 
after running ANT again, had the GC not occurred).
Comment 12 Darin Swanson CLA 2003-02-07 11:50:24 EST
*** Bug 29421 has been marked as a duplicate of this bug. ***
Comment 13 ulrich köster CLA 2003-02-07 12:01:30 EST
I`ve found a workaround for it:

Class AntCorePlugin from plugin org.eclipse.core.ant:
.
.
.
public class AntCorePlugin extends Plugin {

	private static AntClassLoader antClassLoader;
Comment 14 ulrich köster CLA 2003-02-07 12:04:29 EST
I`ve found a workaround for it:

Class AntCorePlugin from plugin org.eclipse.core.ant:
.
.
.
public class AntCorePlugin extends Plugin {

	private static AntClassLoader antClassLoader;
Comment 15 ulrich köster CLA 2003-02-07 12:09:12 EST
Created attachment 3364 [details]
AntCorePlugin
Comment 16 ulrich köster CLA 2003-02-07 12:09:52 EST
I`ve found a workaround for it:

Class AntCorePlugin from plugin org.eclipse.core.ant is attached.

This means that Eclipse has to be restarted whenever there are changes to the
Ant classpath in the preferences. But thats much better then getting OutOfMemory
exceptions.
Comment 17 Darin Swanson CLA 2003-02-07 12:37:19 EST
Looking at the patch, you have added caching of the AntClassLoader instead of 
recreating the class loader for each build.

In fact previous to M4 we did exactly that.

This was identified as a memory leak. Some Ant tasks that execute leak memory 
and there is no way to guarantee that they don't. Without creating a new 
classloader every time we could not protect Eclipse from this problem. 
So unfortunately, I do not believe this is a solution but thanks anyways.
Comment 18 Darin Swanson CLA 2003-02-08 14:13:36 EST
*** Bug 29961 has been marked as a duplicate of this bug. ***
Comment 19 Wendell Beckwith CLA 2003-02-09 00:58:48 EST
This is the only serious issue I have found with 2.1 M4 and 2.1 M5/RC0 is this
leaking of mem.  I run eclipse on Windows XP with the command line "eclipse.exe
-vm <path to 1.4.1 vm> -data <path to workspace>"  and by using ant internally I
get about 23 invocations before my process is reported as being 18xMB and I die.
 Actually most times the IDE zombies and I have to manually kill it.
Comment 20 ulrich köster CLA 2003-02-11 04:33:48 EST
Comment #17

This means it's better having all ant tasks leaking instead of some?

How about fixing the leaking ant tasks instead of trying to fix them with a workaround in eclipse?
     
Comment 21 Darin Swanson CLA 2003-02-11 08:49:46 EST
It would be great if you worked with Apache Ant to identify and help them fix 
any tasks that might be leaking.
Comment 22 ulrich köster CLA 2003-02-12 04:30:05 EST
How about using the solution from tomcat. In the Tomcat plugin has all we need. PluginClassloaderWrapper WebAppClassloader a.s.o.

Yes, a classloader without leaking. :-)
Comment 23 Brian Deng CLA 2003-02-17 10:07:39 EST
How about executing ant as an external process?  This might also provide for 
another feature which I would be interested in, namely the ability to use 
different Java versions for different ANT Builds.

Sorry if this has already been suggested and shot down.
Comment 24 Darin Swanson CLA 2003-02-17 10:17:45 EST
Definately not shot down...we just ran out of time.
But it is currently possible..we just don't provide all the support that we 
would like to.  Please see bug 24129.
Comment 25 Darin Swanson CLA 2003-02-18 15:04:19 EST
Ulrich, can you provide details on how the tomcat classloaders can guarantee no 
leakage. 
I am no expert but I do not think that this is possible. As an example some of 
the leaks we are seeing occur because of Threads being registered for Runtime 
shutdown hooks etc
Comment 26 Darin Swanson CLA 2003-02-19 15:31:45 EST
On build I20030218, using Optimizeit Profiler 4.2 enterprise edition I am 
having trouble finding many cases where we are leaking.
The case I have found is running the xdoclet.ejb.EjbDocletTask task. A 
reference to the org.apache.log4j.LogManager class remains after the build. A 
static variable of this class pretty much holds on to the rest of the Ant 
world. Optimizeit is not showing any instances of LogManager remaining and does 
not show references to classes (at least not that I can find). Can the 
community help shed some light on this problem?

Can anyone provide a different test case?
The builds I am trying, the org.eclipse.ant.internal.core.AntClassLoader is 
getting garbage collected. This is the classloader we use to load the Ant 
classes used for the build.
Comment 27 Darin Swanson CLA 2003-02-19 15:50:42 EST
As well see http://nagoya.apache.org/bugzilla/show_bug.cgi?id=17216 (Execute 
task and the ProcessDestoryer memory leak).
Comment 28 Wendell Beckwith CLA 2003-02-19 15:58:44 EST
Well this may be the thing for me.  I didn't notice a memory leak until I
started using xdoclet which was around the same time I started with RC0.  I just
create a 2nd ant build file which just does an exec against the 1st build file
and I can still see my memory going up but at a reduced rate.  Previously it
would go up at approx. 6MB per execution and not it seems to only be 1.2MB per
execution.  This 1.2MB may be related to the ProcessDestoryer memory leak
previously memtioned.
Comment 29 Jim Allers CLA 2003-02-20 10:56:18 EST
The list of tasks which will exhibit the ProcessDestroyer memory leak is long.
javac (default compiler adapter and fork=true, Jikes adapter)
javadoc
cvs
cvspass
cvstagdiff
cvschangelog
exec
junit (forked)
... at least 15 more
Comment 30 Jim Allers CLA 2003-02-20 14:09:13 EST
I have an ant jar which patches the ProcessDestroyer memory leak (as far as I
can tell). I can attach it if anyone is interested.
Comment 31 Darin Swanson CLA 2003-02-20 20:04:17 EST
Released some changes to the Eclipse integration build listeners 
(AntProcessBuildListener and ProgressBuildListener) to null out as much state 
as possible so a little bit more can be gc'd
Comment 32 Jim Allers CLA 2003-02-26 11:01:41 EST
Created attachment 3718 [details]
"kit" to produce patched Ant 1.5.1 for ProcessDestroyer

The patch I submitted to Ant for the ProcessDestroyer leak was accepted for the
1.6 milestone (see comment #27 or
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=17216).

I am attaching a zip which includes a build script and the patched
ProcessDestroyer which can be used against an existing ant 1.5.1 distribution
to produce a patched ant 1.5.1 jar.

To create a patched 1.5.1 using the zip, simply extract the zip to a directory
and run ant in that directory. The ant script requires "ant.home" to be set to
the ant home directory. It will produce an ant-patch.jar in that directory.

The patch is created by extracting the classes from the Ant 1.5.1 release and
replacing only the ProcessDestroyer class file. A new jar is created
(ant-patch) using the existing Ant 1.5.1 class files and the new
ProcessDestroyer class files. An attribute is added to the manifest indicating
that it is a patched ant jar.
Comment 33 Marc Wilson CLA 2003-02-27 21:43:42 EST
I patched the ant.jar in eclipse 2.1 M5/RC0 but I am still experiencing the 
memory leaks causing eclipse to shutdown when I run numerous Ant builds that 
execute XDoclet tasks.

Could someone confirm whether or not this patch has fixed the problem for them.
Comment 34 Darin Swanson CLA 2003-02-27 22:30:47 EST
The ProcessDestroyer patch will not fix the leak(s) that I was profiling when 
executing a build that used the xdoclet.ejb.EjbDocletTask task.
Comment 35 Darin Swanson CLA 2003-03-06 10:34:29 EST
*** Bug 33391 has been marked as a duplicate of this bug. ***
Comment 36 Darin Swanson CLA 2003-03-07 11:19:15 EST
Marking as won't fix but really it is can't fix.
The solution / workaround is for us to implement bug 24129.
Comment 37 Caoilte O'Connor CLA 2003-03-10 05:57:24 EST
I just wanted to say that after evaluating eclipse for our workplace, we have 
decided not to switch largely because of this bug. 
 
With large projects, importing a dozen or so jars, it only takes half an hour or so 
for an outofmemoryexception to kill the workspace. This is after setting the heap 
to 256meg or larger. 
 
I don't mean to belittle the great work done on eclipse, I hope things come 
togethor in the future. 
Comment 38 Wendell Beckwith CLA 2003-03-10 17:20:28 EST
A workaround seems to be to invoke ant as an external program.  I have setup
external launchers with cmd.exe as the tool and passing ags of '/c "ant
ejbdoclet ..." and the memory usage is orders better.
Comment 39 Darin Swanson CLA 2003-03-10 17:25:11 EST
Yes this will work as you running Ant in a separate vm which terminates on 
completion of the build. See comment #24 and bug 24129 for further 
clarification and examples.
Comment 40 Darin Swanson CLA 2003-03-11 11:32:18 EST
*** Bug 33906 has been marked as a duplicate of this bug. ***
Comment 41 Darin Swanson CLA 2003-03-12 11:18:36 EST
*** Bug 32336 has been marked as a duplicate of this bug. ***
Comment 42 Darin Swanson CLA 2003-03-21 14:39:31 EST
*** Bug 35503 has been marked as a duplicate of this bug. ***
Comment 43 John Arthorne CLA 2003-03-27 12:33:28 EST
*** Bug 35751 has been marked as a duplicate of this bug. ***
Comment 44 Peter Svahn CLA 2003-04-01 01:38:07 EST
*** Bug 35864 has been marked as a duplicate of this bug. ***
Comment 45 Darin Swanson CLA 2003-04-04 12:15:25 EST
*** Bug 36072 has been marked as a duplicate of this bug. ***
Comment 46 Darin Swanson CLA 2003-04-09 10:00:15 EDT
*** Bug 36048 has been marked as a duplicate of this bug. ***
Comment 47 ulrich köster CLA 2003-04-17 04:11:39 EDT
Hi,

I've tried to integrate the Classloader from the tomcat project unfortunatly this does not help. 
Anyway you may find it usefull that the objectstyle team relesead a patched 
org.eclipse.core.ant_2.1.0 plugin.You can download it from http://sourceforge.net/project/
showfiles.php?group_id=50507.

Ulrich
Comment 48 Darin Swanson CLA 2003-04-17 08:16:39 EDT
Thanks for the information Ulrich, but do you know what the patch entails? The 
release notes for the patch make no indication of what has been changed.
Comment 49 ulrich köster CLA 2003-04-17 09:46:00 EDT
The patch includes the AntCorePlugin attachment from this bugreport.

We can't wait until all memory holes are fixed in ant, the jvm or whatever. With Eclipse 2.1 it's not 
possible to use ant. Please do me a favour and look at it from the user point of view. What is more 
important:
1. Good looking code in Eclipse but no ant support. 10 runs until there is no more memory for the 
classloader and the vm halts. Or imagine a user with 10 projects. The unlucky developer don't 
even get a chance to build his projects. Okay it's possible to increase the memory size which 
brings us to 2 rebuild all.
2. A hack that enables the ant usage. Same classloader for each ant run and a day were you can do 
the job payed for.

There are so many people with headaches about that. Don't get me wrong I don't have the 
intention to offend you. I have the feeling that this is more a problem of priority rather then a 
technical problem.  As far as I understand it, the AntCorePlugin set's up a new ClassLoader for 
each ant run to avoid memory leaks. That is a goog thing. But the fix results in other more 
problems.

Ulrich
Comment 50 Jim Allers CLA 2003-04-17 10:15:32 EDT
Does someone have a list of ant tasks known to leak memory?

I know that almost all of the tasks that launch an external process leak 
memory. See Comment #29. 

With the patch of the ProcessDestroyer leak, I can run all of my build files 
without leaking memory. None of my custom tasks leak memory, and none of the 
core tasks or optional tasks that I run leak.

I think the solution that keeps the ClassLoader resident in memory will still 
lead to frustrating memory leaks, albeit a *lot* slower. I prefer the external 
tool-> Program solution, see bug 24129.
Comment 51 Darin Swanson CLA 2003-04-17 18:30:53 EDT
*** Bug 36639 has been marked as a duplicate of this bug. ***
Comment 52 Andrew Baldwin CLA 2003-04-20 09:02:32 EDT
*** Bug 36678 has been marked as a duplicate of this bug. ***
Comment 53 Darin Swanson CLA 2003-04-23 09:22:11 EDT
*** Bug 36781 has been marked as a duplicate of this bug. ***
Comment 54 Darin Swanson CLA 2003-04-24 08:04:00 EDT
*** Bug 36827 has been marked as a duplicate of this bug. ***
Comment 55 ulrich köster CLA 2003-04-25 02:21:23 EDT
The external tool stuff won't help in my case. I launch Ant programatically. The external tools don't 
provide a public api. I totally agree with you that the resident classloader still leaks. A crash after 
12 hours is much better then one after 2 minutes.

Ulrich
Comment 56 Darin Swanson CLA 2003-04-25 09:12:00 EDT
Ulrich, can you open a separate bug with your usecase for being able to 
programatically designate reuse of the AntClassLoader. Thanks.
Comment 57 Darin Swanson CLA 2003-04-25 09:13:44 EDT
*** Bug 36812 has been marked as a duplicate of this bug. ***
Comment 58 Darin Swanson CLA 2003-05-07 17:23:17 EDT
Just a note that an alpha version of integrated support for launching Ant in a 
separate VM is provided in the latest integration builds. See bug 24129 for 
more details.
Comment 59 Darin Swanson CLA 2003-05-14 15:48:19 EDT
*** Bug 37616 has been marked as a duplicate of this bug. ***
Comment 60 Darin Swanson CLA 2003-06-05 15:42:12 EDT
*** Bug 38338 has been marked as a duplicate of this bug. ***
Comment 61 Darin Swanson CLA 2003-06-05 15:43:01 EDT
*** Bug 37912 has been marked as a duplicate of this bug. ***
Comment 62 Darin Wright CLA 2003-06-18 09:50:33 EDT
*** Bug 38990 has been marked as a duplicate of this bug. ***
Comment 63 Darin Swanson CLA 2003-07-08 18:04:56 EDT
*** Bug 39118 has been marked as a duplicate of this bug. ***
Comment 64 John Arthorne CLA 2003-07-28 14:50:53 EDT
*** Bug 40250 has been marked as a duplicate of this bug. ***
Comment 65 Rasmus Back CLA 2003-08-21 03:06:59 EDT
*** Bug 41646 has been marked as a duplicate of this bug. ***
Comment 66 Darin Swanson CLA 2003-10-23 08:32:26 EDT
*** Bug 45424 has been marked as a duplicate of this bug. ***
Comment 67 Darin Swanson CLA 2003-10-31 15:57:38 EST
*** Bug 45889 has been marked as a duplicate of this bug. ***
Comment 68 Darin Swanson CLA 2003-11-03 11:48:56 EST
*** Bug 45948 has been marked as a duplicate of this bug. ***
Comment 69 Darin Swanson CLA 2003-11-13 02:50:31 EST
*** Bug 46218 has been marked as a duplicate of this bug. ***
Comment 70 Darin Swanson CLA 2003-11-17 17:52:51 EST
*** Bug 46790 has been marked as a duplicate of this bug. ***
Comment 71 Agent Smith CLA 2003-11-22 14:05:22 EST
People, this really sucks!

Do you expect me to read all this crap to check what I have to do to fix the 
problem MYSELF with a "workaround"?

I expect to read a short solution and not dozens of postings!

And I don't expect to apply a patch which don't work (build error). I simply 
want a patched file and you to tell me where to copy it. Please!

This is a bad bug handling which is done here!
Comment 72 Ed Burnette CLA 2003-11-22 17:32:08 EST
This one should probably be marked 'fixed in 3.0' since 3.0m5 defaults to run 
ant in its own VM now.
Comment 73 Darin Swanson CLA 2003-12-23 23:06:28 EST
The outstanding XDoclet issue:
http://opensource.atlassian.com/projects/xdoclet/secure/ViewIssue.jspa?key=XDT-
419
Comment 74 Darin Swanson CLA 2004-02-27 15:28:02 EST
Generally this is "fixed" in 3.0 with the fixes in the Apache Ant code base and 
Eclipse defaulting to run Ant builds in a separate VM.

Changing subject so maybe people will find this bug instead of logging 
duplicates.
Comment 75 Darin Swanson CLA 2004-02-27 15:28:58 EST
*** Bug 53318 has been marked as a duplicate of this bug. ***
Comment 76 Darin Swanson CLA 2004-04-10 23:57:12 EDT
*** Bug 58075 has been marked as a duplicate of this bug. ***
Comment 77 Darin Swanson CLA 2004-05-17 11:41:01 EDT
*** Bug 62489 has been marked as a duplicate of this bug. ***
Comment 78 Darin Swanson CLA 2005-02-24 16:19:24 EST
*** Bug 86523 has been marked as a duplicate of this bug. ***
Comment 79 Robert Lee CLA 2005-10-20 03:47:53 EDT
Has the bug been fixed ?

Thanks
Comment 80 Nikolay Metchev CLA 2006-01-16 12:54:47 EST
I am getting similar errors to those described in this bug with Eclipse 3.1.1. That version of eclipse is using Ant 1.6.5 so it should not be leaking. I am not running ant in a seperate JVM. Have all measures been taken to ensure that ant doesn't leak?
Comment 81 Darin Swanson CLA 2006-01-16 13:02:11 EST
> I am getting similar errors to those described in this bug with Eclipse 3.1.1.
> That version of eclipse is using Ant 1.6.5 so it should not be leaking. I am
> not running ant in a seperate JVM. Have all measures been taken to ensure that
> ant doesn't leak?
This is a very hard question for the Eclipse Ant integration to answer. I have done extensive testing to ensure that our integration implementation does not leak. 
Can I test all Ant tasks and infrastructure to ensure that it does not leak? The answer is an obvious no. 
Any Ant build with its likely unique series of tasks run in the same JRE as Eclipse has the potential to leak especially when most tasks make the assumption that they will execute once and then the VM will exit.

What I would suggest is that the community take the time to profile the build that is suspected of leaking and report the bug(s) to the responsible party...be it Eclipse or Ant. The second best alternative is to log a reproducible bug report with test case and buildfile so I can determine exactly where the leak is. Note this should be a new bug report and not an addition to this behemoth :-)
Comment 82 Mark Melvin CLA 2006-02-03 11:37:27 EST
Well, this is coming back to bite us again as well.  We are using AntRunner programmatically to run an Ant-based builder based on CppTasks.  We use the platform runtime only version of Eclipse as the starting point for our IDE (we do not want the added bloat of the JDT - which Ant UI requires), so we do not have access to the Ant UI stuff.  This means, I also do not have the option of running the Ant builder in a separate VM without a HUGE amount of work and code duplication.  Anyway, if you run repeated Ant builds the platform will eventually run out of memory and crash.  

I have tried to profile this, but I must admit, I don't really know what I am doing.  I am trying the YourKit Java profiler, and I have managed to confirm that the leak is in fact the org.eclipse.ant.internal.core.AntClassLoader class.  I took a memory snapshot, ran 5 builds in a row, and lo and behold there are 5 instances of AntClassLoader kicking around, each referencing megabytes of other objects.  I tried to profile with object allocation turned on, but every profiler I have tried simply crashes when you try this.  I think this has to do with the way AntRunner mucks with classloaders or something, because it always gets into the build then just crashes violently.

Anyway - I have no idea where to look next.  Can look at the retained instances of AntClassLoader and see that the classes Vector contains 641 Object references.  Good luck figuring out which one is at fault...

So, I have exported a dump of the AntClassLoader object in HTML form and I'll attach it to this bug, but I can't make heads or tails of it.  I have no idea how to determine what is at fault here.

Since I am dealing with AntRunner programmatically, is there any way to explicitly force an object to be deleted?  I am setting my AntRunner class to null when I am finished, but obviously that isn't helping.  There are no instances of AntRunner left in my profiling snapshots, so it is getting cleaned up properly.  What the heck is holding onto the AntClassLoader then?  <sigh>  I wish I knew more about this stuff...
Comment 83 Mark Melvin CLA 2006-02-03 11:38:31 EST
Created attachment 34091 [details]
Dump of AntClassLoader object
Comment 84 Darin Swanson CLA 2006-02-03 11:45:44 EST
Thanks Mark for the information.
Any class that is leaked and was loaded by a particular class loader will cause the class loader to not be able to be GC'd. I will look at the dump but needle in a haystack does come to mind.

What would really allow me to get to the bottom of this is to log a new bug report with a buildfile, that when run repeatedly as a same JRE build causes an OOM failure. Then I can profile to find who and what is leaking.
Comment 85 Mark Melvin CLA 2006-02-03 11:55:35 EST
I can try to minimize this down to a simple build file, and I'll file a new bug if I do.  That could be difficult however, because we have our own builder calling AntRunner, which in turn uses CppTasks, as well as our own extensions to CppTasks.  It will get a little complicated.  If I had to guess I would say CppTasks is the culprit.  I have found numerous bugs in that package, and I am rapidly trying to figure out an exit plan in the back of my mind to get away from using it at all, now that we have shipped products based on it. ;o)