title: What is the correct way to set ANT_OPTS in OS X?
body: <p>I'm running into 'Error: Java heap space, java.lang.OutOfMemoryError: Java heap space' when compiling an existing project on OS X (Snow Leopard). </p>
  
  <p>I am using the default Java 1.6 64-bit SDK, and default install of Ant (both are provided as part of the OS). </p>
  
  <p>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.</p>
  
  <p>I tried setting ANT_OPTS as follows:</p>
  
  <p>In the same shell I entered</p>
  
  <p>export ANT_OPTS="-Xmx1024m'
  ant build</p>
  
  <p>I also tried setting the value in ~/.bash_profile (which I sourced to ensure it was picked up).</p>
  
  <p>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).</p>
  
  <p>What is the correct way to increase the amount on Heap memory when running Ant in OS X? </p>
  
  <p><b>UPDATE:</b> </p>
  
  <p>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). </p>
  
  <p>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? </p>