Ant runs into an infinite loop/throws an OutOufMemoryError
Applies to:
Ant, Mac OS X
Description:
Occurs while compiling project under Mac OS X
Cause:
Apple’s Java VMs reside in /System/Library/Frameworks/JavaVM.framework/Versions/X.Y.Z and JAVA_HOME will usually be something like /System/Library/Frameworks/JavaVM.framework/Versions/X.Y.Z/Home.
Inside this home directory there is a symbolic link named shared_bundle that links three levels up, i.e. to /System/Library/Frameworks/JavaVM.framework.
If your build file contains a fileset like
Ant is going to follow the shared_bundle symlink and ends up recursing into all your installed VMs. Even worse, it will enter /System/Library/Frameworks/JavaVM.framework/Versions/X.Y.Z/Home and will once again follow the same symlink.
Ant versions after Ant 1.7.1 will detect the infinite loop they are in, but the resulting fileset may still be too big to deal with, in particular if you have many different VM versions installed. The problem is amplified by the fact that each installed version has a shared_bundle symlink in it.
One solution is to not allow the fileset to follow symbolic links at all, like in
another one excludes the shared_bundle directories:
For Ant 1.7.1 and earlier excluding shared_bundle may not be enough since there is another symlink bundle that points to the Home directory and will cause infite recursions as well.