I ran across a little tip tonight I thought I should share. Trying to perform a large Salesforce Code migration with Ant kept giving me the following error: Out of memory. Increase Heap Size.

This is a Java error indicating that the virtual machine is out of memory. So now I know what the problem is, what next? If I was launching from a command line changing the heap size is not that tough. Just look up the options for java and set a new value, but I’m using Ant. Looking at the Ant shell script or batch file was no help.

Well a bit of Googling turned up that Ant looks for an environment variable called ANT_OPTS which is use to set Java parameters. Just set the environment variable and off you go. So I added the following to increase the heap size:

export ANT_OPTS=-Xmx256m

That sets the maximum heap size to 256 Megabytes. So if you ever need to increase the size of the Ant JVM, now you know how.