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

相关推荐
Yeats_Liao16 分钟前
Spring 框架:配置缓存管理器、注解参数与过期时间
java·spring·缓存
Yeats_Liao16 分钟前
Spring 定时任务:@Scheduled 注解四大参数解析
android·java·spring
码明16 分钟前
SpringBoot整合ssm——图书管理系统
java·spring boot·spring
某风吾起20 分钟前
Linux 消息队列的使用方法
java·linux·运维
xiao-xiang23 分钟前
jenkins-k8s pod方式动态生成slave节点
java·kubernetes·jenkins
取址执行35 分钟前
Redis发布订阅
java·redis·bootstrap
墨楠。36 分钟前
数据结构学习记录-树和二叉树
数据结构·学习·算法
S-X-S1 小时前
集成Sleuth实现链路追踪
java·开发语言·链路追踪
快乐就好ya1 小时前
xxl-job分布式定时任务
java·分布式·spring cloud·springboot
文城5211 小时前
Mysql存储过程(学习自用)
数据库·学习·mysql