Results 1 to 20 of 20

Thread: Java Heap Space

  1. #1
    Join Date
    Jan 2008
    Posts
    24
    Rep Power
    0

    Thumbs up Java Heap Space

    I am getting "Java Heap Space" Exception while trying to upload xml data into mysql database......I need help....


    How to get rid of this "Java Heap Space"...

    I tried to set Catalina_opts to no use.....

    I also tried re-installing Java....

    nothing worked...help me...:)

  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

    In simple word it's memory leak of your application. May be after updating your file still open and try to do the same again and again.

  3. #3
    danielstoner's Avatar
    danielstoner is offline Senior Member
    Join Date
    Apr 2008
    Location
    Canada
    Posts
    191
    Rep Power
    7

    Default

    You can try to increase the amount of memory Java uses. to do this you have to specify parameters on the command line

    -Xms<size> set initial Java heap size
    -Xmx<size> set maximum Java heap size

    Example: java -Xms64M -Xmx512M ....

    This will start the JVM with 64 MB of memory reserved and will allow increase up to 512 MB. Of course you can specify more. If you are reading a big XML file with DOM that will consume lots of memory. You can also try SAX (if you don't already)
    I guess you are using Tomcat. In this situation you have to look at Tomcat startup scripts and modify the way Java JVM is started with the parameters I specified.
    Daniel @ [www.littletutorials.com]
    Language is froth on the surface of thought

  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

    Yep, DOM use a lots of memory. SAX not much. If your application is not a larger one, better to try it.

  5. #5
    prabhurangan is offline Member
    Join Date
    May 2008
    Posts
    69
    Rep Power
    0

    Default

    Hi DanielStoner,

    How to increase my java heap size using the command given by you. is it ok to run the command from command line... or i should set classpath for java. Please guide me to solve this issue. Due to low memory my system start up is very slow and it takes huge time to open any application. Also i face java heap space problem.

    Regards,
    Prabhu.

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

  7. #7
    prabhurangan is offline Member
    Join Date
    May 2008
    Posts
    69
    Rep Power
    0

    Default

    Hi Eranga,

    Great day to you.
    I have done as said by DanielStoner, but nothing is happened. If i try that command through command prompt, it is displaying the options command screen. Also i have administrator rights.

    Regards,
    Prabhu.

  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

    What you mean by options command window. If that command fail error message is prompt. If not, I think anything is not displayed to the screen.

  9. #9
    prabhurangan is offline Member
    Join Date
    May 2008
    Posts
    69
    Rep Power
    0

    Default

    Dear Eranga,

    When i type the command given by daniel, im getting the list of options for shortcut key commands. If you are not clear. Ok we can stop here. However eranga, if i run the command, i could not see the process done, instead is there any other way to increase the heap size of java, im using netbeans ide, when opening the ide i face this issue.

  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

    Once someone doesn't clear what you say, doesn't mean that discussion should be stop. ;)

    Since you are working on NetBeans why are you worrying about those things? Use the NetBeans configuration file.

  11. #11
    prabhurangan is offline Member
    Join Date
    May 2008
    Posts
    69
    Rep Power
    0

    Default

    Hi Eranga,

    Sorry i did not mean that way. I do not know how to let you know the things happening for me thats why i said like that. Im ready to have discussions a lot with my seniors like you.

    If i use netbeans, we can configure the java heap size for it. Ok if so, i will work on it and let you know.

    Regards,
    Prabhu.

  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

    Config file is located at etc folder in the NetBeans installation folder. Option you have to change is netbeans_default_options

  13. #13
    prabhurangan is offline Member
    Join Date
    May 2008
    Posts
    69
    Rep Power
    0

    Default

    Hi Eranga,

    netbeans_default_options="-J-Xms512m -J-Xmx512m -J-XX:PermSize=32m -J-XX:MaxPermSize=160m -J-Xverify:none -J-Dapple.laf.useScreenMenuBar=true"

    I have increased the maximum and min. size to 512, before it was mini. 32m and maxim. 128m, but should i have to increase the permSize also to that extent or let it be as such, or shall i increase the permSize and MaxPermSize to to some extent.

    Regards,
    Prabhu.

  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

    Default

    Increase MaxPermSize only. And also you can decrees Xms as well, but it can cause UI responsive issues if the OutOfMemory reach. In that case you have to increase it again. You can keep PermSize as it is, that amount is fine work out smoothly.

  15. #15
    prabhurangan is offline Member
    Join Date
    May 2008
    Posts
    69
    Rep Power
    0

    Default

    Thank you very much Eranga, for guiding me. However while start-up my pc is very slow, so i have formatted my os, and for the next three days everything went fine, but again now it is very slow to boot-up. Can you please let me know the reason for it. What shall i do to rectify this situation.

    Regards,
    Prabhu.

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

  17. #17
    prabhurangan is offline Member
    Join Date
    May 2008
    Posts
    69
    Rep Power
    0

    Default

    Before making these changes, i was facing this issue. I have a 2GB Ram size. But even now i noted it after shuting down my pc and logging again, it is taking more time to boot-up.....

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

    This type of issue can cause because of the maximum size you have allocated to NetBeans. Logically it cannot happen, since you don't have open NetBeans. But practically it happen because page file keep those records at the system shutdown. Then when you boot up again, located memory for boot-up can be not enough. May be you have lots of application to run at startup.

    Seems that your PC have an issue too, I wonder since you have 2GB or memory NetBeans giving such heap size issue.

  19. #19
    prabhurangan is offline Member
    Join Date
    May 2008
    Posts
    69
    Rep Power
    0

    Default

    I can understand eranga, is there any solution to get rid of these performance issue. While start up of my pc. But i could not understand why it was working fine when i formated my os and for next three days it was booting up fine and now it gets slow.

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

Similar Threads

  1. java.lang.OutOfMemoryError: Java heap space
    By paul in forum Advanced Java
    Replies: 11
    Last Post: 06-12-2010, 06:30 PM
  2. Heap Sort in Java
    By Java Tip in forum Algorithms
    Replies: 0
    Last Post: 04-16-2008, 11:27 PM
  3. Space Exploration dev 6
    By JavaBean in forum Java Software
    Replies: 0
    Last Post: 03-25-2008, 05:48 PM
  4. Print a blank space
    By susan in forum New To Java
    Replies: 2
    Last Post: 07-30-2007, 02:58 PM
  5. Java Heap Out of Memory Error
    By stonkers in forum New To Java
    Replies: 3
    Last Post: 07-17-2007, 05:43 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
  •