Even though you have free RAM, the JVM may not have access to it. You can increase the JVM heap size by giving certain parameters.
For example,
java -ms64M -mx128M example.MyClass
starts the JVM with an initial heap size of 64 megabytes and gives it permission to grow up to 128 megabytes. The JVM will not exceed the mx-value.