The JVM could not be started. The main method may have thrown an exception

This Windows specific problem can occur if Java Virtual Machine can't allocate the specified amount of memory in a single continuous chunk when you start the IDE.

Recent IDE versions with the new launcher fail with this error instead: Failed to create JVM: error code -4.

IDE runs in 32-bit mode by default which limits the total amount of process memory that can be addressed to 2GB on most Windows versions.

Even if the maximum heap size (-Xmx) is set to just 512m, you can still observe this problem for the following reasons:

  • Heap size is not the total memory limit, the value of -XX:PermSize is also added to this number, plus stack size for every thread, plus memory mapped files, plus internal JVM memory for the JIT compiler and other needs. All these factors make it easy to get close or exceed the 2GB value.
  • Even if total memory doesn't exceed the OS limit, JVM requires all the heap memory to be continuous. There might be no such chunk available in the address space to fit in the heap.
  • Address space fragmentation can heavily limit the maximum heap size that can be used. Your system may have a lot of different application installed and running. Some applications inject DLLs into the address space of other processes leading to fragmentation. Use the DLLs view (Ctrl+D) in the Process Explorer to find out what apps injected their hooks into the IDE process. Some common dynamic libraries that you can observe: TortoiseOverlays.dll, mdnsNSP.dll, DropboxExt.dll. The more third-party libraries you see there, the higher is the chance that the address space will get fragmented and you will get this error even with low heap values.
  • IDE .exe launcher can itself cause additional fragmentation, we are using a third-party tool for this launcher and do not have full control over it, but in the future updates we'll migrate to our own launcher that should reduce the fragmentation. IntelliJ IDEA 13.1.x+ versions have a new launcher version that doesn't cause memory fragmentation because of the splash screen.


  • Reduce -Xmx and -XX:PermSize values in IDE_HOME\bin\<product>.exe.vmoptions file, try to do it step by step reducing by 100m every time until it starts. Refer to the Configuring JVM options and platform properties for details.
  • Start in 64-bit mode, for example IntelliJ IDEA provides idea64.exe launcher that will use 64-bit JDK found in the registry (you have to install it separately).
  • Start the IDE using <product>.bat file instead of the .exe (also useful if 64-bit executable is not provided for your product).
  • .bat script will use 32-bit JDK by default (from the .\jre directory), you can override it with the environment variable pointing to the 64-bit JDK installation home, the variable would depend on the product: IDEA_JDK for IntelliJ IDEA, PHPSTORM_JDK for PhpStorm since version 2016.1, WEBIDE_JDK for PhpStorm before version 2016.1 and WebStorm, PYCHARM_JDK for PyCharm, RUBYMINE_SDK for RubyMine. See Selecting the JDK version the IDE will run under for more details.
  • Reduce the number of applications fragmenting the process address space by uninstalling those you don't use.
17 out of 56 found this helpful

For 1st bullet, had to bring memory down do 50m. Not workable. Am using the 64-bit mode, which may even be a performance improvement.


I had trouble trying to use the 64 bit version - when I read the fine print, it said to download a full 64 bit JDK, not the JRE.

I downloaded v 8.2 on windows at

and the 64 bit version of PHPStorm worked like a champ!


I was getting the error "Failed to create JVM: error code -4". Couldn't find that anywhere in the Googleverse, so thought I'd add it here. Contacted Support to get this link.

I opted for the 64 Bit solution, as I'm on a 64 Bit system. Thanks to Jack above for saving me some time finding the correct JDK download!

Here's the steps that worked for me:

1) Download and install the JDK from the link Jack provided above:

2) Find the PHPStorm 64 Bit EXE and launch it.

3) If you are a fan of convenience, make sure to replace any desktop, taskbar, or start menu links with the 64 Bit version!


for Linux Distribution 

edit ~/.IdeaICXXXX/config/idea64.vmoptions  

and change ReservedCodeCacheSize=2048m


There is no point to set ReservedCodeCacheSize to more than 300m. You are just wasting RAM without gaining any performance.


Please sign in to leave a comment.

Have more questions?

Submit a request