Question & Answer
Question
How to overcome java.lang.OutOfMemoryError when running an ant command?
Answer
A java.lang.OutOfMemoryError occurs when no additional memory can be allocated in the JVM for use by the application. To overcome this error, we would need to allocate extra memory to the JVM. When running an ant command, JVM parameters can be passed by setting the ANT_OPTS parameter. Here is an example of how it could be done (in Windows):
set ANT_OPTS=-Xms512m -Xmx768m -XX:MaxPermSize=256m
The above statement would allocate 512 MB of memory as the initial (ms) heap size, 768 MB of memory as the maximum (mx) heap size, and 256 MB as the maximum permanent generation space in the JVM. The above is only an example; Certain processes might require more memory than what has been shown in the example. In such cases, the values of the parameters should to be increased accordingly. Moreover, the system hardware should also be adequate to allocate the necessary memory to the JVM.
The ANT_OPTS parameter should be set before running the ant command.
Historical Number
HTG2760
Was this topic helpful?
Document Information
Modified date:
16 June 2018
UID
swg21562127