Results 1 to 17 of 17
  1. #1
    itmani2020 is offline Member
    Join Date
    Jun 2008
    Posts
    23
    Rep Power
    0

    Default Wanted help on "java.lang.OutOfMemoryError: Java heap space"

    Hi,
    When i m trying to navigate through in my application i m getting this exception"java.lang.OutOfMemoryError: Java heap space+Java"..
    When i did some analysis on this i got its something i want to pass the size as argument.can anyone help on it..............

    Thanks in Advance,
    Mani:)

  2. #2
    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

    What type of application you tested. Is it given an error on a simple application too, like print 'Hello World'

  3. #3
    Niveditha's Avatar
    Niveditha is offline Senior Member
    Join Date
    May 2008
    Posts
    307
    Rep Power
    7

    Default

    I think u have created so many objects that jvm has no memory to store anything else.

    if ur application is really huge then, Why dont u do a garbage collection?

    But b4 all that check what Eranga suggested u it may b problem with JVM too.
    To finish sooner, take your own time....
    Nivedithaaaa

  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

  5. #5
    itmani2020 is offline Member
    Join Date
    Jun 2008
    Posts
    23
    Rep Power
    0

    Default

    @Eranga
    its not a simple application it consist of heavy load at the database.............can any one help me in increase the heap size in eclipse or in JRE.....................

    Thanks ,
    Mani

  6. #6
    Niveditha's Avatar
    Niveditha is offline Senior Member
    Join Date
    May 2008
    Posts
    307
    Rep Power
    7

    Default

    Hey Pal,
    U have taken Eranga in a wrong way. His stmt
    Start from the simple things. It's much better all the time.
    was for
    Is it given an error on a simple application too, like print 'Hello World'
    If ur application is huge then do a garbage collection or
    check this link to increase heap size it gives u 2 ways of doing it.
    Increase heap size in Java to prevent java.lang.OutOfMemoryError
    To finish sooner, take your own time....
    Nivedithaaaa

  7. #7
    Niveditha's Avatar
    Niveditha is offline Senior Member
    Join Date
    May 2008
    Posts
    307
    Rep Power
    7

    Default

    And remeber one thing no one here is waiting here with readymade answers to help u out, they are just sharing their knowledge with u. :rolleyes:

    Before writing anything read all the posts and then reply ok...
    Being rude or short-tempered is not going to help u out in IT industry. :)
    To finish sooner, take your own time....
    Nivedithaaaa

  8. #8
    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

    Well said Niveditha, as you said no one here to write code here for others. I don't think any one wants to do it. Sometimes we give code, because we can see he/she make an attempt and failed to get the correct way.

    And also, don't be hurry. Please read the post carefully before commenting any.

    Keep in mind, because of such behaviors can be in 'not to replay' list for many members. It's not good my friends.

  9. #9
    Niveditha's Avatar
    Niveditha is offline Senior Member
    Join Date
    May 2008
    Posts
    307
    Rep Power
    7

    Default

    Thank you Eranga :)
    And i am sorry mani if i was bit rude...
    To finish sooner, take your own time....
    Nivedithaaaa

  10. #10
    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

    No not at all. All these well let because as you said a forum is a place where we can share our knowledge. You tried point out that to all, that's it.

  11. #11
    itmani2020 is offline Member
    Join Date
    Jun 2008
    Posts
    23
    Rep Power
    0

    Default

    Hey niveditha ,

    i understood what eranga replied............
    but for simple application its not occuring......this will happen only when i m trying to load heavy the data..............

    sorry if i hurted someone.
    My intension here is not to hurt members.just to help and get rid of that bug.............anyway sorry once more.

  12. #12
    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

    No one hurt on anyone itmani. :)

    We always advice in good ways, that's it. So don't worry.

    Before giving any comments best thing is start from the simple step. That's why ask that simple application and so on. As you said IDE not hurt you on a simple application. That means your real application has a problem.

    Since it's a DB related application, lots of reasons can be cause. Mainly the way you handle connects, data sets and so on.

    Why we advice such things, just increase the heap size not always best. When you increase the heap size it cause to your whole system(PC).

    Check on IDE options, there may be some options to change those values. There should minimum as well as maximum values. I can't say exactly how it done, because I never work on Eclipse.

  13. #13
    itmani2020 is offline Member
    Join Date
    Jun 2008
    Posts
    23
    Rep Power
    0

    Default

    ya eranga....
    after some depth search at google....they mentioned if we run the eclipsce from cmd prompt we r able to give attribute.......i m trying to debugg that issue.....i think i m in right path............

    Cheers,
    Mani

  14. #14
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

  15. #15
    sheena06 is offline Member
    Join Date
    Jul 2008
    Posts
    4
    Rep Power
    0

    Default

    lesson not only for java related but also how to deal with others.. well, that's good everyone.. :)

  16. #16
    skaspersen is offline Member
    Join Date
    Jul 2008
    Posts
    31
    Rep Power
    0

    Default

    Are you using JDBC?
    If this is the case the problem is probably that you are not closing statements and resultsets when you are done with them.

    The mysql driver uses native code and allocates memory that is not in control of the garbage collector. This memory will only be freed when you call Statement.close(),PreparedStatement.close(), and ResultSet.close().

    Good programming example for JDBC.

    Java Code:
    PreparedStatement ps = null;
    ResultSet rs = null;
    try{
        ps = connection.prepareStatement("Select *from table where table.somefield=?");
        ps.setString(1,"StringValue");
        rs = ps.executeQuery();
        while(rs.next()){
            //MAKE USE OF RESULTS
        }
    }catch(SqlException e){
    } finally{
        if(rs!=null){
             try{
                   rs.close();
             } catch(SqlException e1){
             }
        }
        if(ps!=null){
             try{
                   ps.close();
             } catch(SqlException e1){
             }
        }
    }

  17. #17
    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

    Yes the best thing is check all conditions that you have safely exit. It can be caused to have more problems.

    And also if you want, you can call the garbage collector by your self.

Similar Threads

  1. Replies: 8
    Last Post: 03-05-2011, 04:53 AM
  2. java.lang.OutOfMemoryError: Java heap space
    By paul in forum Advanced Java
    Replies: 11
    Last Post: 06-12-2010, 06:30 PM
  3. Replies: 14
    Last Post: 06-12-2008, 09:36 AM
  4. Replies: 1
    Last Post: 07-25-2007, 11:55 PM
  5. Replies: 1
    Last Post: 07-16-2007, 07:32 AM

Posting Permissions

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