Results 1 to 9 of 9
  1. #1
    guest_user is offline Member
    Join Date
    May 2011
    Posts
    47
    Rep Power
    0

    Default What is the default heap size of a java program?

    I get the OutOfHeapMemory exception or something, what should I do? how can I check the current heap size of a java program?

  2. #2
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,798
    Rep Power
    7

    Default

    Why do you want to know?

    If you are running out of memory then examine your code to find out where your leaks are. You can use a profiler to help. Otherwise you can up the memory by using the -Xmx option.

  3. #3
    guest_user is offline Member
    Join Date
    May 2011
    Posts
    47
    Rep Power
    0

    Default

    How does java leak memory?

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,086
    Rep Power
    20

    Default

    If you hold onto stuff you really don't need to be holding onto.

  5. #5
    guest_user is offline Member
    Join Date
    May 2011
    Posts
    47
    Rep Power
    0

    Default

    Quote Originally Posted by Tolls View Post
    If you hold onto stuff you really don't need to be holding onto.
    1) When a thread dies, that is, if the isAlive() returns false, are the references within the thread get garbage collected?
    2) In java, do I have to join a thread in order to free up resources like in the C language(pthreads)?

  6. #6
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,086
    Rep Power
    20

    Default

    If you still hold onto the thread object I'm not sure anything it references will die. Depends how you've written it.
    The resources are freed if you have written your code such that the references are no longer reachable. So the garbage collector can collect them.

  7. #7
    fxRichard is offline Member
    Join Date
    Dec 2008
    Posts
    64
    Rep Power
    0

    Default

    Default is 64mb starting and 256mb max

  8. #8
    guest_user is offline Member
    Join Date
    May 2011
    Posts
    47
    Rep Power
    0

    Default

    Quote Originally Posted by Tolls View Post
    If you still hold onto the thread object I'm not sure anything it references will die. Depends how you've written it.
    The resources are freed if you have written your code such that the references are no longer reachable. So the garbage collector can collect them.
    what about 2)
    In java, do I have to join a thread in order to free up resources like in the C language(pthreads)?

  9. #9
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,086
    Rep Power
    20

    Default

    If you're talking about memory then there's really no such thing as freeing up memory in Java.
    You just need to make sure the objects you create only exist in the scope they are required.

Similar Threads

  1. Changing default Applet Viewer Size?
    By dsym@comcast.net in forum Java Applets
    Replies: 6
    Last Post: 08-27-2010, 06:42 PM
  2. Heap size
    By newbiejava in forum New To Java
    Replies: 2
    Last Post: 08-22-2010, 11:59 AM
  3. get maximum heap size that can be allocated
    By gautam.aditya97 in forum Java 2D
    Replies: 3
    Last Post: 04-05-2010, 05:03 AM
  4. [SOLVED] JAVA heap size problem
    By sreedevi in forum New To Java
    Replies: 3
    Last Post: 02-11-2009, 07:05 AM
  5. Java heap size
    By jmdrocks in forum Eclipse
    Replies: 2
    Last Post: 12-12-2008, 06:10 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
  •