I'm running into 'Error: Java heap space, java.lang.OutOfMemoryError: Java heap space' when compiling an existing project on OS X (Snow Leopard).
I am using the default Java 1.6 64-bit SDK, and default install of Ant (both are provided as part of the OS).
I have encountered this issue in other OS environments and normally solve it by using ANT_OPTS to increase the allocated memory but this does not appear to be working.
I tried setting ANT_OPTS as follows:
In the same shell I entered
export ANT_OPTS="-Xmx1024m' ant build
I also tried setting the value in ~/.bash_profile (which I sourced to ensure it was picked up).
I eventually solved the memory problem by increasing the memory in the javac task in my Ant script, but this is not ideal (I would much rather use ANT_OPTS).
What is the correct way to increase the amount on Heap memory when running Ant in OS X?
UPDATE:
It appears I was wrong and ANT_OPTS is being picked up as excepted. The problem is that I am forking the javac task (as described by bkail below).
Which leads me to my next question. Why does the JAVAC process keep running out of memory on OSX when the same code/ant script works fine on Linux? What is different about the default OSX install of Java that means it requires additional memory allocated?