Latest Entries
May 15

How To Increase Heap Size for ANT’s OutOfMemory Error using ANT_OPTS

ant1Ever run into an ANT compilation or ANT task related compilation OutOfMemoryError problem? This little bugger of a problem can be rather tricky to debug. You may run into this problem when you have a large collection of source files to compile (think 1000+). You may also run into this problem with the following WebLogic ANT tasks:

1. jwsc
2. wlappc (LARGE JSP Pre-Compilations)

There may be other related compilation tasks, but bottom line is the Java Heap Size is too small. To increase it, you need to add $ANT_OPTS to your environment. An overkill, but also a sure way to fix the problem can be these values:

ANT_OPTS=”-Xmx1024m -Xms512m”

This variable must be set within your build machine’s environment. When ANT executes, it automatically includes $ANT_OPTS in its execution string. I hope this little hint will solve a lot of your future headaches. I’ve been troubleshooting a similar problem on a project I’m currently working on for the past 24 hours.  We went from plan a, to b, to c, to d, and started to run into a dead end and wanted to go for a temp fix by disabling pre-compilation.. until I found this root cause.

If you’re not currently using $ANT_OPTS, perhaps you should look into implementing that on your infrastructure. May end up saving you a heap of debugging time down the road. :)

2 Responses to “How To Increase Heap Size for ANT’s OutOfMemory Error using ANT_OPTS”

  1. AndrewBoldman said:

    Great post! Just wanted to let you know you have a new subscriber- me!

  2. Freddy said:

    In mac OSX ANT_OPTS might also be set by editing
    ~/.antrc.

    For example, ~/.antrc might contain this.
    export ANT_OPTS=-Xmx512m

    If this file exists, exporting to ANT_OPTS will be ignore.

Leave a Reply


Related Topics:

No related posts.