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

    Default [SOLVED] JAVA heap size problem

    Hi,

    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
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    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
    Posts
    68
    Rep Power
    0

    Default

    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 ...you can use any memory physically available for JVM.

    ____________________________________________
    Priya,
    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
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

    Default

    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.

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

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, 06:28 PM
  2. Java heap size
    By jmdrocks in forum Eclipse
    Replies: 2
    Last Post: 12-12-2008, 07:10 AM
  3. Java Heap Space
    By sandeeprao.techno in forum Advanced Java
    Replies: 19
    Last Post: 10-30-2008, 12:27 PM
  4. Java heap space?
    By javanewbie in forum New To Java
    Replies: 1
    Last Post: 06-24-2008, 07:55 PM
  5. Heap Sort in Java
    By Java Tip in forum Algorithms
    Replies: 0
    Last Post: 04-16-2008, 11: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
  •