Does adding -Xmx argument when running a Java program cause the garbage collector to act differently or occur less often?
Does adding -Xmx argument when running a Java program cause the garbage collector to
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Yes, most Java garbage collectors only run as needed, as opposed to running on a schedule whether needed or not. So, in general, more memory causes less frequent, longer garbage collections.
The generational garbage collectors have settings to control the allocation of memory between the young and tenured generations. By setting these to use a smaller proportion of total memory for the young generation, the absolute size of the young generation can be kept the same as the total heap size is increased. Then, you won’t see much of a change in garbage collection frequency or duration—but you will have more room for long-lived objects for applications like caching.