Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 995759
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T06:46:17+00:00 2026-05-16T06:46:17+00:00

The JVM -Xmx argument lets one set the max heap size for the JVM

  • 0

The JVM -Xmx argument lets one set the max heap size for the JVM to some value. But, is there a way to make that value dynamic? In other words, I want to tell the JVM “look, if you need it, just keep taking RAM from the system until the system is out.”

Two-part reason for asking:
First, the app in question can use a really wide range of ram depending on what the user is doing, so the conceptual min and max values are pretty far apart. Second, it would seem that the JVM reserves the max heap space from virtual memory at boot time. This particular app is run on a pretty wide variety of hardware, so picking a “one-size-fits-all” max heap space is hard since it has to be low enough to run on low-end hardware, but we’d really like to be able to take advantage of really beefy machines if they’re available.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T06:46:18+00:00Added an answer on May 16, 2026 at 6:46 am

    But, is there a way to make that value dynamic?

    Literally, no. The max heap size is set at JVM launch time and cannot be increased.

    In practice, you could just set the max heap size to as large as your platform will allow, and let the JVM grow the heap as it needs. There is an obvious risk in doing this; i.e. that your application will use all of the memory and cause the user’s machine to grind to a halt. But that risk is implicit in your question.

    EDIT

    It is worth noting that there are various -XX... GC tuning options that allow you to tweak the way that the JVM expands the heap (up to the maximum).

    Another possibility is to split your application into 2 parts. The first part of the application does all of the preparation necessary to determine the “size” of the problem. Then it works out an appropriate max heap size, and launches the memory hungry second part of the application in a new JVM.

    • This only works if the application can sensibly be partitioned as above.

    • This only works if it is possible to compute the problem size. In some cases, computing the problem size is tantamount to computing the result.

    • It is not clear that you will get better overall performance than if you just let the heap grow up to a maximum size.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically we've noticed that on some computers setting the JVM option -Xmx (max heap
Possible Duplicates: Setting JVM heap size at runtime programatically setting max java heap size
The theoretical maximum heap value that can be set with -Xmx in a 32-bit
I'm trying to figure out if there's a way to determine the JVM startup
How can I set the JVM memory limit (-Xmx option for Java) for my
There are lots of parameters for JVM. Some start with - , such as
I see some strange behavior on the maximum heap size I get on Sun's
Our design has one jvm that is a jboss/webapp (read/write) that is used to
There have been many JVM languages in the recent few years including Javascript, Python,
How does the JVM make it's windows, i know it has it's jar files

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.