zoukankan      html  css  js  c++  java
  • Eclipse – Java.Lang.OutOfMemoryError: Java Heap Space(转)

    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

    eclipse-out-of-memory
     

    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/

  • 相关阅读:
    MATLAB——sigmoid传递函数
    MATLAB——BP神经网络
    MATLAB——神经网络构造线性层函数linearlayer
    MATLAB——线性神经网络
    MTALAB——神经网络mae()、mse()、sse()
    详解 Java 中的三种代理模式!
    HTTP 无状态中的状态到底指的是什么?
    单例模式的 8 种写法,整理非常全!
    数据库连接池到底应该设多大?
    Spring 框架用到的 9 个设计模式汇总!
  • 原文地址:https://www.cnblogs.com/bluestorm/p/3663836.html
Copyright © 2011-2022 走看看