[Intellij] insufficient memory for the Java Runtime Environment 에러 해결법, vmoption 변경하는 법
평소에 잘 되던 Intellij가 갑자기 아래 에러가 뜨더니 Crash 되버리고 갑자기 꺼져버리는 일이 생겼다.
#
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (malloc) failed to allocate 1182736 bytes for Chunk::new
# Possible reasons:
# The system is out of physical RAM or swap space
# The process is running with CompressedOops enabled, and the Java Heap may be blocking the growth of the native heap
# Possible solutions:
# Reduce memory load on the system
# Increase physical memory or swap space
# Check if swap backing store is full
# Decrease Java heap size (-Xmx/-Xms)
# Decrease number of Java threads
# Decrease Java thread stack sizes (-Xss)
# Set larger code cache with -XX:ReservedCodeCacheSize=
# JVM is running with Unscaled Compressed Oops mode in which the Java heap is
# placed in the first 4GB address space. The Java Heap base address is the
# maximum limit for the native heap growth. Please use -XX:HeapBaseMinAddress
# to set the Java Heap base and to place the Java Heap above 4GB virtual address.
# This output file may be truncated or incomplete.
#
# Out of Memory Error (arena.cpp:191), pid=9520, tid=30636
#
# JRE version: OpenJDK Runtime Environment JBR-17.0.9+7-1000.46-jcef (17.0.9+7) (build 17.0.9+7-b1000.46)
# Java VM: OpenJDK 64-Bit Server VM JBR-17.0.9+7-1000.46-jcef (17.0.9+7-b1000.46, mixed mode, tiered, compressed oops, compressed class ptrs, g1 gc, windows-amd64)
# No core dump will be written. Minidumps are not enabled by default on client versions of Windows
#
--------------- S U M M A R Y ------------
Command Line: exit -XX:ErrorFile=C:\Users\\java_error_in_idea64_%p.log -XX:HeapDumpPath=C:\Users\\java_error_in_idea64.hprof -Xms128m -Xmx2048m -XX:ReservedCodeCacheSize=512m -XX:+UseG1GC -XX:SoftRefLRUPolicyMSPerMB=50 -XX:CICompilerCount=2 -XX:+HeapDumpOnOutOfMemoryError -XX:-OmitStackTraceInFastThrow -XX:+IgnoreUnrecognizedVMOptions -XX:CompileCommand=exclude,com/intellij/openapi/vfs/impl/FilePartNodeRoot,trieDescend -ea -Dsun.io.useCanonCaches=false -Dsun.java2d.metal=true -Djbr.catch.SIGABRT=true -Djdk.http.auth.tunneling.disabledSchemes="" -Djdk.attach.allowAttachSelf=true -Djdk.module.illegalAccess.silent=true -Dkotlinx.coroutines.debug=off -Xmx2048m -Dfile.encoding=UTF-8 -Dconsole.encoding=UTF-8 -Djb.vmOptionsFile=C:\Users\AppData\Roaming\\JetBrains\\IdeaIC2023.2\idea64.exe.vmoptions -Djava.system.class.loader=com.intellij.util.lang.PathClassLoader -Didea.vendor.name=JetBrains -Didea.paths.selector=IdeaIC2023.2 -Djna.boot.library.path=C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2023.2.5/lib/jna/amd64 -Dpty4j.preferred.native.folder=C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2023.2.5/lib/pty4j -Djna.nosys=true -Djna.noclasspath=true -Didea.platform.prefix=Idea -Dsplash=true -Daether.connector.resumeDownloads=false --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.ref=ALL-UNNAMED --add-opens=java.base/java.lang.reflect=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.nio=ALL-UNNAMED --add-opens=java.base/java.nio.charset=ALL-UNNAMED --add-opens=java.base/java.text=ALL-UNNAMED --add-opens=java.base/java.time=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.util.concurrent=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED --add-opens=java.base/jdk.internal.vm=ALL-UNNAMED --add-opens=java.base/sun.nio.ch=ALL-UNNAMED --add-opens=java.base/sun.nio.fs=ALL-UNNAMED --add-opens=java.base/sun.security.ssl=ALL-UNNAMED --add-opens=java.base/sun.security.util=ALL-UNNAMED --add-opens=java.base/sun.net.dns=ALL-UNNAMED --add-opens=java.desktop/java.awt=ALL-UNNAMED --add-opens=java.desktop/java.awt.dnd.peer=ALL-UNNAMED --add-opens=java.desktop/java.awt.event=ALL-UNNAMED --add-opens=java.desktop/java.awt.image=ALL-UNNAMED --add-opens=java.desktop/java.awt.peer=ALL-UNNAMED --add-opens=java.desktop/java.awt.font=ALL-UNNAMED --add-opens=java.desktop/javax.swing=ALL-UNNAMED --add-opens=java.desktop/javax.swing.plaf.basic=ALL-UNNAMED --add-opens=java.desktop/javax.swing.text.html=ALL-UNNAMED --add-opens=java.desktop/sun.awt.datatransfer=ALL-UNNAMED --add-opens=java.desktop/sun.awt.image=ALL-UNNAMED --add-opens=java.desktop/sun.awt.windows=ALL-UNNAMED --add-opens=java.desktop/sun.awt=ALL-UNNAMED --add-opens=java.desktop/sun.font=ALL-UNNAMED --add-opens=java.desktop/sun.java2d=ALL-UNNAMED --add-opens=java.desktop/sun.swing=ALL-UNNAMED --add-opens=java.desktop/com.sun.java.swing=ALL-UNNAMED --add-opens=jdk.attach/sun.tools.attach=ALL-UNNAMED --add-opens=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-opens=jdk.internal.jvmstat/sun.jvmstat.monitor=ALL-UNNAMED --add-opens=jdk.jdi/com.sun.tools.jdi=ALL-UNNAMED -Dide.native.launcher=true -Djcef.sandbox.ptr=000001D7048F5060
Host: Intel(R) Core(TM) i5-6200U CPU @ 2.30GHz, 4 cores, 7G, Windows 10 , 64 bit Build 19041 (10.0.19041.3636)
Time: Sun Feb 11 17:00:13 2024 Windows 10 , 64 bit Build 19041 (10.0.19041.3636) elapsed time: 303.078632 seconds (0d 0h 5m 3s)
--------------- T H R E A D ---------------
Current thread (0x000001d731721b80): JavaThread "C2 CompilerThread0" daemon [_thread_in_native, id=30636, stack(0x000000c9d2500000,0x000000c9d2600000)]
Current CompileTask:
C2: 303078 56238 ! 4 com.intellij.ide.plugins.cl.PluginClassLoader::tryLoadingClass (595 bytes)
Stack: [0x000000c9d2500000,0x000000c9d2600000]
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V [jvm.dll+0x6886e9]
V [jvm.dll+0x841e4a]
V [jvm.dll+0x843a8e]
V [jvm.dll+0x8440f3]
V [jvm.dll+0x24c14f]
V [jvm.dll+0xac44c]
V [jvm.dll+0xaca9c]
V [jvm.dll+0x36c1f7]
V [jvm.dll+0x1be6a2]
V [jvm.dll+0x21df09]
V [jvm.dll+0x21d1d1]
V [jvm.dll+0x1a674d]
V [jvm.dll+0x22d088]
V [jvm.dll+0x22b1c0]
V [jvm.dll+0x7f62f7]
V [jvm.dll+0x7f06aa]
V [jvm.dll+0x687565]
C [ucrtbase.dll+0x21bb2]
C [KERNEL32.DLL+0x17344]
C [ntdll.dll+0x526b1]
com.intellij.diagnostic.JBRCrash
위와 같은 에러가 뜨면 어떻게 해결해야 할까?
결론적으로 Runtime environment의 memory가 부족하다는 말이니 bin 폴더의 vmoption을 조정해주었다. (사실 위의 에러 메세지를 자세히 살펴보면 해결방안도 제시해주는데
# Decrease Java heap size (-Xmx/-Xms)
그 중에서 위를 솔루션으로 사용해보기로 했다)
나는 Intellij 에서 해당 에러가 나서 JetBrains 폴더에서 설치된 Intellij 경로에 있는 vmoptions라는 파일을 찾아주었다.
사람마다 경로가 다를 수 있는데
IDE_HOME\bin\[제품명].exe.vmoptions
위 경로에서 위 파일을 찾아주면 된다.
그런 다음에 해당 파일을 열면