The “java.lang.OutOfMemoryError: Java heap space” error will be triggered when you try to add more data into the heap space area in memory, but the size of this data is larger than the JVM can accommodate in the Java heap space.
Note that the amount of memory your Java application is eligible to consume is specified during the JVM startup (via -Xmx and -XX:MaxPermSize parameters for example). And in your case, giving more memory to compiler will not help the runtime - try increasing the max allowed heap size of the actual runtime instead of the compiler.
It is generally as easy as adding or increasing the value of parameter similar to the following, where the com.mycompany.MyProgram is allowed to use up to 1G of heap memory:
java -Xmx1024m com.mycompany.MyProgram