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

相关推荐
咖啡教室4 小时前
java日常开发笔记和开发问题记录
java
咖啡教室4 小时前
java练习项目记录笔记
java
鱼樱前端4 小时前
maven的基础安装和使用--mac/window版本
java·后端
RainbowSea5 小时前
6. RabbitMQ 死信队列的详细操作编写
java·消息队列·rabbitmq
RainbowSea5 小时前
5. RabbitMQ 消息队列中 Exchanges(交换机) 的详细说明
java·消息队列·rabbitmq
李少兄7 小时前
Unirest:优雅的Java HTTP客户端库
java·开发语言·http
此木|西贝7 小时前
【设计模式】原型模式
java·设计模式·原型模式
云上艺旅7 小时前
K8S学习之基础七十四:部署在线书店bookinfo
学习·云原生·容器·kubernetes
可乐加.糖7 小时前
一篇关于Netty相关的梳理总结
java·后端·网络协议·netty·信息与通信
s9123601017 小时前
rust 同时处理多个异步任务
java·数据库·rust