IDEA 学习之 编译内存问题

目录

      • [1. 正常的 IDEA build 日志](#1. 正常的 IDEA build 日志)
      • [2. 编译工具内存不足日志 (内存从小变大)](#2. 编译工具内存不足日志 (内存从小变大))
        • [2.1. 干脆无法启动](#2.1. 干脆无法启动)
        • [2.2. Ant 任务执行报错](#2.2. Ant 任务执行报错)
        • [2.3. 内存溢出:超出 GC 上限](#2.3. 内存溢出:超出 GC 上限)
        • [2.4. 内存溢出:超出 GC 上限,编译报错](#2.4. 内存溢出:超出 GC 上限,编译报错)
        • [2.5. 内存溢出: 堆空间](#2.5. 内存溢出: 堆空间)
        • [2.6. 内存溢出: 内存不足](#2.6. 内存溢出: 内存不足)
        • 解决方案

1. 正常的 IDEA build 日志

java 复制代码
Executing pre-compile tasks...
Loading Ant configuration...
Running Ant tasks...
Running 'before' tasks
Checking sources
Copying resources... [user]
Parsing java... [user]
java: JPS incremental annotation processing is disabled. Compilation results on partial recompilation may be inaccurate. Use build process "jps.track.ap.dependencies" VM flag to enable/disable incremental annotation processing environment.
Writing classes... [user]
Checking dependencies... [user]
Dependency analysis found 0 affected files
Updating dependency information... [user]
Adding @NotNull assertions... [user]
Adding pattern assertions... [user]
Adding the Threading Model assertions... [user]
Running 'after' tasks
javac 1.8.0_333 was used to compile java sources
Finished, saving caches...
Executing post-compile tasks...
Loading Ant configuration...
Running Ant tasks...
Synchronizing output directories...
2022/10/13, 10:04 AM - Build completed successfully with 2 warnings in 5 sec, 563 ms

2. 编译工具内存不足日志 (内存从小变大)

2.1. 干脆无法启动
2.2. Ant 任务执行报错
java 复制代码
Executing pre-compile tasks...
Loading Ant configuration...
Running Ant tasks...
Internal error (java.lang.NullPointerException): null
java.lang.NullPointerException
	at com.intellij.util.containers.hash.LinkedHashMap$Entry.access$200(LinkedHashMap.java:283)
	at com.intellij.util.containers.hash.LinkedHashMap.doRemoveEldestEntry(LinkedHashMap.java:137)
	at com.intellij.util.io.FilePageCache.ensureSize(FilePageCache.java:218)
	at com.intellij.util.io.FilePageCache.get(FilePageCache.java:186)
	at com.intellij.util.io.PagedFileStorage.getBufferWrapper(PagedFileStorage.java:370)
	at com.intellij.util.io.PagedFileStorage.getBuffer(PagedFileStorage.java:345)
	at com.intellij.util.io.PagedFileStorage.put(PagedFileStorage.java:246)
	at com.intellij.util.io.PagedFileStorage.fillWithZeros(PagedFileStorage.java:321)
	at com.intellij.util.io.PagedFileStorage.resize(PagedFileStorage.java:295)
	at com.intellij.util.io.ResizeableMappedFile.expand(ResizeableMappedFile.java:120)
	at com.intellij.util.io.ResizeableMappedFile.ensureSize(ResizeableMappedFile.java:89)
	at com.intellij.util.io.ResizeableMappedFile.putInt(ResizeableMappedFile.java:210)
	at com.intellij.util.io.PersistentEnumeratorBase.markDirty(PersistentEnumeratorBase.java:576)
	at com.intellij.util.io.PersistentEnumeratorBase.<init>(PersistentEnumeratorBase.java:143)
	at com.intellij.util.io.PersistentBTreeEnumerator.<init>(PersistentBTreeEnumerator.java:96)
	at com.intellij.util.io.PersistentEnumerator.createDefaultEnumerator(PersistentEnumerator.java:67)
	at com.intellij.util.io.PersistentMapImpl.<init>(PersistentMapImpl.java:136)
	at com.intellij.util.io.PersistentMapBuilder.buildImplementation(PersistentMapBuilder.java:62)
	at com.intellij.util.io.PersistentMapBuilder.build(PersistentMapBuilder.java:44)
	at com.intellij.util.io.PersistentHashMap.<init>(PersistentHashMap.java:39)
	at com.intellij.util.io.PersistentHashMap.<init>(PersistentHashMap.java:54)
	at org.jetbrains.jps.incremental.storage.AbstractStateStorage.createMap(AbstractStateStorage.java:116)
	at org.jetbrains.jps.incremental.storage.AbstractStateStorage.<init>(AbstractStateStorage.java:29)
	at org.jetbrains.jps.incremental.storage.FileTimestampStorage.<init>(FileTimestampStorage.java:27)
	at org.jetbrains.jps.incremental.storage.ProjectStamps.<init>(ProjectStamps.java:42)
	at org.jetbrains.jps.cmdline.BuildRunner.load(BuildRunner.java:102)
	at org.jetbrains.jps.cmdline.BuildSession.runBuild(BuildSession.java:324)
	at org.jetbrains.jps.cmdline.BuildSession.run(BuildSession.java:175)
	at org.jetbrains.jps.cmdline.BuildMain$MyMessageHandler.lambda$channelRead0$0(BuildMain.java:218)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:750)
Executing post-compile tasks...
Loading Ant configuration...
Running Ant tasks...
Synchronizing output directories...
2022/10/13, 9:51 AM - Build completed with 1 error and 0 warnings in 1 sec, 582 ms
2.3. 内存溢出:超出 GC 上限
java 复制代码
Executing pre-compile tasks...
Loading Ant configuration...
Running Ant tasks...
build: Project rebuild forced: Storage version updated, file = /Users/zxguan/Library/Caches/JetBrains/IntelliJIdea2022.1/compile-server/springcloud2_9578806c/timestamps/data
Cleaning output directories...
Running 'before' tasks
Checking sources
Copying resources... [user]
Parsing java... [user]
java: JPS incremental annotation processing is disabled. Compilation results on partial recompilation may be inaccurate. Use build process "jps.track.ap.dependencies" VM flag to enable/disable incremental annotation processing environment.
java: java.lang.OutOfMemoryError: GC overhead limit exceeded
java: java.lang.OutOfMemoryError: GC overhead limit exceeded
Checking dependencies... [user]
2.4. 内存溢出:超出 GC 上限,编译报错
java 复制代码
Executing pre-compile tasks...
Loading Ant configuration...
Running Ant tasks...
Running 'before' tasks
Checking sources
Copying resources... [user]
Parsing java... [user]
java: JPS incremental annotation processing is disabled. Compilation results on partial recompilation may be inaccurate. Use build process "jps.track.ap.dependencies" VM flag to enable/disable incremental annotation processing environment.
java: 系统资源不足。
java: 有关详细信息,请参阅以下堆栈跟踪。
java: java.lang.OutOfMemoryError: GC overhead limit exceeded
java:   at com.sun.tools.javac.util.List.of(List.java:135)
java:   at com.sun.tools.javac.util.List.append(List.java:272)
java:   at com.sun.tools.javac.comp.Resolve$MethodResolutionContext.addApplicableCandidate(Resolve.java:4338)
java:   at ......
java:   at ......
java: Compilation failed: internal java compiler error
Checking dependencies... [user]
Dependency analysis found 0 affected files
Errors occurred while compiling module 'user'
javac 1.8.0_333 was used to compile java sources
Finished, saving caches...
Executing post-compile tasks...
Loading Ant configuration...
Running Ant tasks...
Synchronizing output directories...
2022/10/13, 9:55 AM - Build completed with 2 errors and 1 warning in 12 sec, 377 ms
2.5. 内存溢出: 堆空间
java 复制代码
Executing pre-compile tasks...
Loading Ant configuration...
Running Ant tasks...
Running 'before' tasks
Checking sources
Copying resources... [user]
Parsing java... [user]
java: JPS incremental annotation processing is disabled. Compilation results on partial recompilation may be inaccurate. Use build process "jps.track.ap.dependencies" VM flag to enable/disable incremental annotation processing environment.
java: java.lang.OutOfMemoryError: Java heap space
java: java.lang.OutOfMemoryError: Java heap space
Checking dependencies... [user]
Dependency analysis found 0 affected files
Errors occurred while compiling module 'user'
javac 1.8.0_333 was used to compile java sources
Finished, saving caches...
Executing post-compile tasks...
Loading Ant configuration...
Running Ant tasks...
Synchronizing output directories...
2022/10/13, 9:55 AM - Build completed with 2 errors and 1 warning in 12 sec, 377 ms
2.6. 内存溢出: 内存不足
java 复制代码
Executing pre-compile tasks...
Loading Ant configuration...
Running Ant tasks...
Running 'before' tasks
Checking sources
Copying resources... [user]
Parsing java... [user]
java: JPS incremental annotation processing is disabled. Compilation results on partial recompilation may be inaccurate. Use build process "jps.track.ap.dependencies" VM flag to enable/disable incremental annotation processing environment.
java: 系统资源不足。
java: 有关详细信息,请参阅以下堆栈跟踪。
java:   at ......
java:   at ......
java:java.lang.OutOfMemoryError: insufficient memory
Checking dependencies... [user]
Dependency analysis found 0 affected files
Errors occurred while compiling module 'user'
javac 1.8.0_333 was used to compile java sources
Finished, saving caches...
Executing post-compile tasks...
Loading Ant configuration...
Running Ant tasks...
Synchronizing output directories...
2022/10/13, 9:55 AM - Build completed with 2 errors and 1 warning in 12 sec, 377 ms
解决方案

调大 IDEA 编译内存大小,File -> Settings -> Build, Execution, Deployment -> Compiler -> Shared build process heap size

相关推荐
xlsw_1 小时前
java全栈day20--Web后端实战(Mybatis基础2)
java·开发语言·mybatis
神仙别闹2 小时前
基于java的改良版超级玛丽小游戏
java
黄油饼卷咖喱鸡就味增汤拌孜然羊肉炒饭3 小时前
SpringBoot如何实现缓存预热?
java·spring boot·spring·缓存·程序员
暮湫3 小时前
泛型(2)
java
超爱吃士力架3 小时前
邀请逻辑
java·linux·后端
南宫生3 小时前
力扣-图论-17【算法学习day.67】
java·学习·算法·leetcode·图论
转码的小石3 小时前
12/21java基础
java
李小白663 小时前
Spring MVC(上)
java·spring·mvc
sanguine__3 小时前
Web APIs学习 (操作DOM BOM)
学习
GoodStudyAndDayDayUp4 小时前
IDEA能够从mapper跳转到xml的插件
xml·java·intellij-idea