Results 1 to 4 of 4
  1. #1
    sreedevi is offline Member
    Join Date
    Feb 2009
    Rep Power

    Default [SOLVED] JAVA heap size problem


    I am facing java heap size problem while running the code.
    My code is very simple, but it has several single and 2 dimentional arrays of size 3619 and 3619x3619. I run my code in Eclipse. It gives me the below error :

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

    My code stops at the declaration of the the array
    double[][] sample=new double[3619][3619];

    Can u tell me how to increase heap size in "Eclipse"?
    What are the jav memory limitations?

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Blog Entries
    Rep Power


    I'd look at the Run -- Open Run Dialog -- Arguments tab -- VM arguments

    But don't hold me to this.

  3. #3
    Join Date
    Oct 2008
    Rep Power


    Think about how much memory you are allocating. JVM by default allocates some memory which may not be sufficient.

    do you know how much memory double variable needs? calculate based on that and then you can use -X option to allocate the memory for your program as shown below

    java -Xmx256m <your class>

    this is example for 256MB can use any memory physically available for JVM.

    Cooking is Fun | Eat Healthy Stay Fit | Sweets | Raita | Bread | Dal| Snacks

  4. #4
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Colombo, Sri Lanka
    Blog Entries
    Rep Power


    Your application has a memory leak me be. Did you try anything work around with the garbage collector within the code. It may helpful to prevent this.

    In default Java heap is 128MB, but in some project it's not enough. Run time you can increase it with the following command.

    java -Xms<initial heap size> -Xmx<maximum heap size>
    I'm not an Eclipse user, but there should be a way to config this. May be through a project config file.

    Did you search the forum? Same question is discuss several times here.

    Additionally, following thread explain this on NetBeans. Not directly related with your question, but it can be helpful to you.

Similar Threads

  1. Problem while writing to file, size greater than 15MB ..?
    By prabhurangan in forum New To Java
    Replies: 3
    Last Post: 12-30-2008, 05:28 PM
  2. Java heap size
    By jmdrocks in forum Eclipse
    Replies: 2
    Last Post: 12-12-2008, 06:10 AM
  3. Java Heap Space
    By sandeeprao.techno in forum Advanced Java
    Replies: 19
    Last Post: 10-30-2008, 11:27 AM
  4. Java heap space?
    By javanewbie in forum New To Java
    Replies: 1
    Last Post: 06-24-2008, 06:55 PM
  5. Heap Sort in Java
    By Java Tip in forum Algorithms
    Replies: 0
    Last Post: 04-16-2008, 10:27 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts