Speed tradeoff of Java's -Xms and -Xmx options

后端 未结 8 1808
北荒
北荒 2020-12-04 08:24

Given these two commands

A:

$ java -Xms10G -Xmx10G myjavacode input.txt

B:

$ java -Xms5G -Xmx5G myjavacode input.tx         


        
相关标签:
8条回答
  • 2020-12-04 09:16

    I have found that in some cases too much memory can slow the program down.

    For example I had a hibernate based transform engine that started running slowly as the load increased. It turned out that each time we got an object from the db, hibernate was checking memory for objects that would never be used again.

    The solution was to evict the old objects from the session.

    Stuart

    0 讨论(0)
  • 2020-12-04 09:19

    The speed tradeoffs between various settings of -Xms and -Xmx depend on the application and system that you run your Java application on. It also depends on your JVM and other garbage collection parameters you use.

    This question is 11 years old, and since then the effects of the JVM parameters on performance have become even harder to predict in advance. So you can try different values and see the effects on performance, or use a free tool like Optimizer Studio that will find the optimal JVM parameter values automatically.

    0 讨论(0)
提交回复
热议问题