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/

Eclipse – Java.Lang.OutOfMemoryError: Java Heap Space(转)的更多相关文章

  1. eclipse内存溢出报错:java.lang.OutOfMemoryError:Java heap space

    今天执行了一个比較大的程序,处理的数据达到126MB数据,将数据导入数据库中,用eclipse 来訪问时候,总是出现java.lang.OutOfMemoryError:Java heap space ...

  2. eclipse:Tomcat设置jvm,解决java.lang.OutOfMemoryError: Java heap space 堆内存溢出

    eclipse 有启动参数里设置jvm大小,因为eclipse运行时自己也需要jvm,所以eclipse.ini里设置的jvm大小不是具体某个程序运行时所用jvm的大小,这和具体程序运行的jvm大小无 ...

  3. eclipse中报错:java.lang.OutOfMemoryError: Java heap space

    问题: 在eclipse中执行java程序.去重100多万的数据,报例如以下错误: java.lang.OutOfMemoryError: Java heap space 异常原因: 在JVM中假设9 ...

  4. Eclipse迅速执行:Exception in thread &quot;main&quot; java.lang.OutOfMemoryError: Java heap space

    问题叙述性说明: Exception in thread "main" java.lang.OutOfMemoryError: Java heap space 问题原因: 程序中对 ...

  5. eclipse运行程序时报java.lang.OutOfMemoryError: Java heap space内存不足问题

    System.setProperty("webdriver.firefox.bin", "D:\\Mozilla Firefox\\firefox.exe"); ...

  6. 解决eclipse maven install 造成JVM 内存溢出(java.lang.OutOfMemoryError: Java heap space)

    maven install 报错信息: The system is out of resources.Consult the following stack trace for details.jav ...

  7. 【转】java.lang.OutOfMemoryError: Java heap space的解决

    原文地址:http://blog.sina.com.cn/s/blog_4b12778b0100v0bb.html Myeclipse下java.lang.OutOfMemoryError: Java ...

  8. 关于java.lang.OutOfMemoryError: Java heap space的错误分析

    今天无意间遇到这个错误:java.lang.OutOfMemoryError: Java heap space 问题出现原因:使用a标签实现快速下载[当然已经实现了,但想了想还是要归纳解决这类问题] ...

  9. Exception in thread "main" java.lang.OutOfMemoryError: Java heap space

    Exception in thread "main" java.lang.OutOfMemoryError: Java heap space解决方法 问题描述 Exception ...

随机推荐

  1. CentOS7下,防火墙设置

    CentOS中防火墙程序主要是firewall和iptables两种. CentOS7中firewall服务已经默认安装好了,而iptables服务需要自己用yum install  iptabes- ...

  2. unset命令详解

    基础命令学习目录首页 功能说明:unset是一个内建的Unix shell命令,在Bourne shell家族(sh.ksh.bash等)和C shell家族(csh.tcsh等)都有实现.它可以取消 ...

  3. Python中fnmatch模块的使用

    fnmatch()函数匹配能力介于简单的字符串方法和强大的正则表达式之间,如果在数据处理操作中只需要简单的通配符就能完成的时候,这通常是一个比较合理的方案.此模块的主要作用是文件名称的匹配,并且匹配的 ...

  4. spring-session实现分布式集群session的共享(转)

    原文: https://www.cnblogs.com/youzhibing/p/7348337.html HttpSession是通过Servlet容器创建和管理的,像Tomcat/Jetty都是保 ...

  5. 在Gulp中使用BrowserSync

    博客已迁移至http://zlwis.me. 很早就听说过BrowserSync,也看过一些相关文章,可就是没用过.之前一直在用Gulp开发项目,每次编写完Sass后还要用按F5刷新页面看效果,想想也 ...

  6. 2017秋软工 —— 本周PSP

    1. PSP 2. PSP饼图 3. 累计进度条 4. 累计折线图

  7. 20162314 《Program Design & Data Structures》Learning Summary Of The First Week

    20162314 2017-2018-1 <Program Design & Data Structures>Learning Summary Of The First Week ...

  8. mybatis 原理

    什么是Mybatis MyBatis 本是apache的一个开源项目iBatis, 2010年这个项目由apache software foundation 迁移到了google code,并且改名为 ...

  9. PHPCMS之 列表和内容页

    上一篇随笔中降到了一些相似的语法可以来后台管理网页的内容,下面就是关于列表的管理 加入一级栏目中有几个有二级菜单的,那么就可以把相应的界面建立一个副本,然后修改里面栏目的一些属性 {pc:conten ...

  10. BETA-6

    前言 我们居然又冲刺了·六 团队代码管理github 站立会议 队名:PMS 530雨勤(组长) 过去两天完成了哪些任务 新方案代码比之前的更简单,但是对场景的要求相应变高了,已经实现,误差感人 代码 ...