I am facing this issue while building my build.xml.
BUILD FAILED
java.lang.OutOfMemoryError: Java heap space
at java.util.Arrays.copyOf(Arrays.java:2786)
(For < Java 8, permgen doesn't apply to Java 8 and up)
For benefit of those who got a similar trace with the word "PermGen" in the Error message,
java.lang.OutOfMemoryError: PermGen space
Increasing the perm-gean space in ANT_OPTS (preferably, though not necessarily along with the Max heap size) should solve the issue
example
export ANT_OPTS="-Xmx2g -XX:MaxPermSize=512m"
Adjust the numbers as per your your need.
Cheers!