Results 1 to 6 of 6
  1. #1
    icesnake is offline Member
    Join Date
    Jun 2010
    Posts
    7
    Rep Power
    0

    Default How to compute or know the correct value for Xmx and xms?

    I have known how to set the Xmx and Xms value for an application but how can I know the correct value for these parameters to optimize the performance of my app? I'm using tomcat 6 and windows xp. Thanks

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,560
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by icesnake View Post
    I have known how to set the Xmx and Xms value for an application but how can I know the correct value for these parameters to optimize the performance of my app? I'm using tomcat 6 and windows xp. Thanks
    Better stay away from them: if your application runs fine, don't touch them; if your application runs out of memory increase the mx value; if it runs out of stack space increase the ms value. For all other situation: leave them alone.

    kind regards,

    Jos

  3. #3
    icesnake is offline Member
    Join Date
    Jun 2010
    Posts
    7
    Rep Power
    0

    Default

    Quote Originally Posted by JosAH View Post
    Better stay away from them: if your application runs fine, don't touch them; if your application runs out of memory increase the mx value; if it runs out of stack space increase the ms value. For all other situation: leave them alone.

    kind regards,

    Jos
    My app had an outOfMemory Java heap error. I know that there are two reasons for it to happen either the max memory allocation is not enough or my app has a memory leak. My question is if I have to increase the max memory allocation, is there a way to know how much I have to increase? or is it just estimation

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

    Default

    Estimation.
    It all comes down to figuring out what it is you're expecting the code to do (that is show big the structures it's expected to work with are)...and profiling. The latter will also help to find memory leaks, or potential memory hot spots where you may be holding onto more data in memory than you actually need to.

  5. #5
    icesnake is offline Member
    Join Date
    Jun 2010
    Posts
    7
    Rep Power
    0

    Default

    Quote Originally Posted by Tolls View Post
    Estimation.
    It all comes down to figuring out what it is you're expecting the code to do (that is show big the structures it's expected to work with are)...and profiling. The latter will also help to find memory leaks, or potential memory hot spots where you may be holding onto more data in memory than you actually need to.
    I have another question, where can I see the allocated Xmx and Xms value if it is not specified? Besides jconsole and profiler is there another way I can see the allocated memory for the application?

    Thanks.

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

    Default

    They'll be the default, which is 2Mb initial (Xms) and 64Mb max (Xmx).

    By the way, Jos has a typo above..it's Xss for the stack size. Xms is the start memory size.

    I will usually define a size for a web server simply because I have never been involved in a project where 64Mb would be sufficient. Also, once you know how much memory your system needs then you may as well set Xms to the same as Xmx since it removes the need for the JVM to grab memory as it's running, and can improve performance after a restart.

Similar Threads

  1. Are my comments correct?
    By twiggy62 in forum New To Java
    Replies: 2
    Last Post: 02-08-2010, 05:34 AM
  2. Getting correct output
    By WarmRegards in forum New To Java
    Replies: 9
    Last Post: 11-01-2009, 04:41 PM
  3. Using Scanner to compute an average of the values
    By Java Tip in forum java.lang
    Replies: 0
    Last Post: 04-17-2008, 07:36 PM
  4. Is my Pseudocode correct?
    By Clemenza1983 in forum New To Java
    Replies: 0
    Last Post: 01-29-2008, 04:07 AM
  5. To correct forum
    By Jman in forum Introductions
    Replies: 3
    Last Post: 01-18-2008, 02:33 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
  •