I am running a very lengthy process through an Ant script, I made the following heap, but still gave me an error.
set ANT_OPTS=-Xms1024M -Xmx2024M -XX:MaxPermSize=512M
It seems strange to me that you use more than 2G to complete the build (although this is obviously possible), so I will make some silly questions to help you think about your problem:
This means that your code is really trying to use more than 2 GB of memory. Use jprofiler, or yourkit, or the built-in JVM tools to figure out what it does and reduce memory usage.
Also, if on a 32-bit machine you cannot get full 2G.
You can also turn on garbage collection logging (details here ) and see why your Heappace is growing so much. It could be a memory leak. Of course, JProfiler will also allow you to do the same. Eclipse 3.4 and above have a profiler into which you can connect to the JVM where your program works if you do not want to use JProfiler.