java: OutOfMemoryError: insufficient memory
1. 调整编译器堆内存大小
操作路径 :
File -> Settings -> Build, Execution, Deployment -> Compiler
-
修改
Build process heap size (MB)值:plaintextBuild process heap size (MB): 2048 # 推荐值(原默认700)
2. 修改IDEA自身JVM配置
操作路径 :
Help -> Edit Custom VM Options
-
添加/修改以下参数:
plaintext-Xms512m # 初始堆内存 -Xmx2048m # 最大堆内存 -XX:ReservedCodeCacheSize=512m # 代码缓存区大小
💡 修改后需重启IDEA生效
3. 优化项目配置
操作入口 :
File -> Project Structure -> Modules
- 禁用未使用的模块
- 清理冗余依赖项
- 检查JDK版本是否匹配项目需求
4. 清理缓存并重启
操作路径 :
File -> Invalidate Caches / Restart
-
选择:
plaintext[ ] Invalidate and Restart [✓] Clear file system cache and Local History [✓] Clear VCS Log caches and indexes