Troubleshooting the “Could not create the Java Virtual Machine” error

This post explains why you might see the “Could not create the Java Virtual Machine” error when creating a SWF or SWC in FlasCC.

When the FlasCC binaries invoke the JVM, the default heap size is set to 2GB. If you are using FlasCC on a machine that does not have sufficient memory, you may see errors like:

Error: Failed to execute compiler: Error occurred during initialization of VM
Could not reserve enough space for object heap
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.

If you run into these errors, you can tweak the JVM heap size by adding the -jvmopt option to the command line options, for example:

gcc -jvmopt="-Xmx1024M" hello.c -o -emit-swf -o hello.swf

Also if you are running on a machine that has spare memory, then you can use the same -jvmopt option to bump up the heap size from its default size.

If you run into issues please ask questions in the FlasCC forums.