Today once I started getting ‘Not enough memory’ while creating the build of a huge project using Ant.
The easy way to increase the heap size is
set ANT_OPTS="-Xms512m -Xmx512m"
For me it worked without the quotes
set ANT_OPTS=-Xms512m -Xmx512m
For setting up the Java Heap size for other app servers and frameworks refer to this link.