In Eclipse IDE, if your program is consuming a lot of memory (loading big data) like this :

  List<Domain> list = domainBo.findAllDomain(100000);
 
for(Domain domain : list){
process(domain.getDomainName());
}

It can easily hit java.lang.OutOfMemoryError: Java heap space :

Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
at java.util.HashMap.<init>(HashMap.java:209)
at java.util.LinkedHashMap.<init>(LinkedHashMap.java:181)

1. Solution – VM arguments

On Eclipse menu, clicks Run -> Run Configurations.., select the Java application you want to run, clicks on theArguments tab, update the VM arguments with the following options

-Xms<size> - Set initial Java heap size
-Xmx<size> - Set maximum Java heap size

For example, -Xms512M -Xmx1024M

 

2. Mistake – eclipse.ini

The memory settings in eclipse.ini is allocated to Eclipse IDE only, not the program you want to run. A very common mistake is updated the heap size in eclipse.ini, and expects it to solve above out of memory problem.

Note
The Java application, Ant / Maven build scripts, or unit test cases, are run as an external tool from Eclipse, and it does not inherit the VM settings in eclipse.ini.

But, if your Eclipse IDE is always crashed by no reason, you can try to increase the heap size and perm gen ineclipse.ini.

/Users/mkyong/Downloads/eclipse/Eclipse.app/Contents/MacOS/eclipse.ini
	-startu
openFile
-showsplash
//...
-XX:MaxPermSize=512m
-Xms512m
-Xmx1024m
//...
-Xdock:icon=../Resources/Eclipse.icns
-XstartOnFirstThread

P.S eclipse.ini is located in the Eclipse installation folder.

Eclipse – java.lang.OutOfMemoryError: Java heap space
http://www.mkyong.com/eclipse/eclipse-java-lang-outofmemoryerror-java-heap-space/

最新文章

  1. js复制内容加版权声明代码
  2. CSS 控制Html页面高度导致抖动问题的原因
  3. JMX整理
  4. [Unity2D]2D Mobile Joystick
  5. 10个常见的IE bug和解决方法
  6. java mail jar冲突
  7. ASP.Net WebForm学习笔记:一、aspx与服务器控件探秘
  8. sql语句实现随机取n条数据(转)
  9. AIX系统上压缩与解压文件
  10. iOS开发之数据存储之XML属性列表(plist)归档
  11. thymeleaf的fragment例子
  12. 《React Native 精解与实战》书籍连载「iOS 平台与 React Native 混合开发」
  13. Python-可变参数和关键字参数(*args **kw)
  14. 深入理解Java中配置环境变量
  15. CentOS7搭建FastDFS V5.11分布式文件系统-第三篇
  16. Ubuntu实用软件安装[转]
  17. 【Cocos2dx 3.x Lua】TileMap使用
  18. Java中常用到的文件操作那些事(一)——替换doc文档模板,生成真实合同案例
  19. Centos 7 环境下,如何使用 Apache 实现 SSL 虚拟主机 双向认证 的详细教程:
  20. p2234&amp;bzoj1588 营业额统计

热门文章

  1. React Native移动开发实战-2-如何调试React Native项目
  2. Linux 学习记录 20170218
  3. 第三周vim入门学习1
  4. cnblogs.com用户体验
  5. c# combobox向上展开
  6. validating &amp; update ctabfolder css
  7. 生命周期事件和 Global.asax 文件
  8. Nginx服务器搭建
  9. Internet History, Technology and Security (Week 4)
  10. Internet History, Technology and Security (Week 3)