Intellij IDEA无法启动:Failed to create JVM:error code -4

首先看官网 如何解释的:


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 theProcess 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.

Solutions

  • 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, WEBIDE_JDK for PhpStorm 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.




解决办法:


 1.减小-Xmx和-XX:PermSize的值

    切换到 IDE_HOME\bin\目录下,找到<product>.exe.vmoptions文件,尝试减少-Xmx和-XX:PermSize的值,建议以100M为单位,直到IDEA可以启动。

    2.开启64位模式

    IDEA提供idea64.exe的启动器,该启动器使用64位的JDK(需要单独安装)。

    3.使用<product>.bat启动

    使用<product>.bat替代.exe启动IDEA。

    4.强制使用64位的JDK

    .bat脚本默认使用32位的JDK(IDEA安装文件的jre 目录下),可以通过环境变量强制使用64位的JDK,变量的值取决于你使用的产品, IDEA_JDK for IntelliJ IDEA, WEBIDE_JDK for PhpStorm and WebStorm, PYCHARM_JDK for PyCharm, RUBYMINE_SDK for RubyMine. 参考 选择合适的JDK 。

    5.卸载不常用的应用程序

    通过卸载不常用的应用程序来减少应用分割进城地址空间。

楼主的是默认的是250m ,减至150m 的时候,启动成功。 


尝试减少-Xmx和-XX:PermSize的值,建议以100M为单位,直到IDEA可以启动。

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值