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.

5 Responses to Troubleshooting the “Could not create the Java Virtual Machine” error

  1. Test says:

    >if you have 32-bit JAVA, uninstall it, and install 64-bit
    …also add JAVA bin folder to your PATH environment variable, default: C:\Program Files\Java\jre7\bin) ..<

    • tony says:

      hello,guys,i have met the same question this morning,but it is a little diffrent,i install 64-bit jre,and add the path.but flassCC still show “jvm ” can not be found.but in the cmd line i can see the jvm exist in my system.and is 64bit!it waste my whole morning,so if you can give me some suggestions,i will be so appreciated!

  2. peter says:

    hi guys, is there any chance you’ll drop this java crap and go with a native compiler (hopefully written in c++)? performance is painfully slow this way.

  3. this person says:

    So, long story short, this error is caused by Java trying to access more ram then is available? I have nearly 6 gigs! Isn’t that plenty?