On 27 Nov 2013, at 16:50, Luke Daley wrote:
Hi,
I've found the source of the file handle leaks on the project I've
been working on.
Ant internally uses an AntClassLoader. It keeps a cache of File →
JarFile (AntClassLoader#jarFiles). This cache holds _open_ JarFile
objects. This cache is designed to be open for the duration of the
build, and then closed at the end. The problem is that we never tell
Ant that the build has finished and therefore it never closes this
cache.
To remedy this, we need to make sure we call fireBuildFinished() on
all ant Project instances when the build is over. For
IsolatedAntBuilder this is easy. Does anyone have any good ideas on
where to do this for Project.getAnt() ?
Forgot to mention, the reason this didn't show up in the profiler is
that JarFile uses JNI and that actual file handle is at the native level
(so YourKit couldn't see it).