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. 【Unity】 Cursor学习

    CursorLockMode.None 光标行为未修改,第一人称视角下鼠标可以突破窗口. CursorLockMode.Locked 光标锁定到游戏窗口的中心,与全屏与否无关,同时隐藏光标(这一点在3 ...

  2. 详细介绍redis的集群功能,带你了解真正意义上的分布式

    Redis 集群是一个分布式(distributed).容错(fault-tolerant)的 Redis 实现, 集群可以使用的功能是普通单机 Redis 所能使用的功能的一个子集(subset). ...

  3. sqlmap 进阶 (一)

    0x1 命令 以此类推,可以具体自己研究有哪些参数,放在哪,有什么用,怎么用 参考:https://blog.csdn.net/bo_mask/article/details/76130848 0x2 ...

  4. Maven打包jar类库

    项目目录>mvn clean compile 编译命令,会在你的项目路径下生成一个target目录,在该目录中包含一个classes文件夹,里面全是生成的class文件及字节码文件. 项目目录& ...

  5. CocoaPods :为iOS程序提供依赖管理的工具(yoowei)

    修改于:2016.11.18   2017.1.10  2019.01.31 CocoaPods 源码 : https://github.com/CocoaPods/CocoaPods CocoaPo ...

  6. unload没有用

    今天下午测试了unload这个事件包括beforeunload <script type="text/javascript"> window.addEventListe ...

  7. 第三周vim入门学习1

    一.vim模式介绍 1.概念:以下介绍内容来自维基百科Vim 从vi演生出来的Vim具有多种模式,这种独特的设计容易使初学者产生混淆.几乎所有的编辑器都会有插入和执行命令两种模式,并且大多数的编辑器使 ...

  8. C#编程概述

    一个简单的c#程序 标识符 标识符是一种字符串,用来命名变量.方法.参数和许多后面将要阐述的其他程序结构. 关键字 所有C#关键字都由小写字母组成,但是.NET类型名使用Pascal大小写约定. Ma ...

  9. python learning GUI

    Hello world1 from tkinter import * # 第一步是导入Tkinter包的所有内容 class Application(Frame): # 第二步是从Frame派生一个A ...

  10. Internet History, Technology and Security (Week 5-2)

    Week 5 (续) Layer 2: Internet Protocol The InterNetwork (IP) 老师强调了一下不用去记住他介绍的人所说的每句话,而是记住要点,了解老师所做的PP ...