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 6340519
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T19:51:04+00:00 2026-05-24T19:51:04+00:00

I see some strange behavior on the maximum heap size I get on Sun’s

  • 0

I see some strange behavior on the maximum heap size I get on Sun’s JVM, compared to JRockit.

I’m running IDEA on 64-bit VMs on a 64-bit system (Ubuntu 11.04). The JVM versions I’m testing are: Java HotSpot(TM) 64-Bit Server VM (build 20.1-b02, mixed mode) (which I got with apt-get install sun-java6-jdk, and Oracle JRockit(R) (build R28.1.3-11-141760-1.6.0_24-20110301-1432-linux-x86_64, compiled mode) (which I downloaded from Oracle’s site a couple of months ago).

If I pass the parameters -Xms1g -Xmx3g, IDEA will report a maximum heap size of 1820M on Sun’s JVM, and 3072M (as expected) on JRockit.

If I pass -Xms2g -Xmx4g, IDEA will report 3640M on Sun’s and 4096M on JRockit.

What is happening? What are those mystic numbers 1820M and 3640M = 2*1820M? Isn’t it possible to run Sun’s JVM with the exact heap size I want?

EDIT:

An answer has been deleted, so just to bring my comments back: please note that I’m talking about the MAX size, not the current size. Consider that I’ve researched a lot before asking the question here, so there’s no need to teach the meaning of Xms, Xmx or any of the other of the parameters that specify the size of regions of the memory (those can be found elsewhere).

EDIT2:

I wrote the following simple code to test this behavior:

public static void main(String[] args) throws Exception {
  while (true) {
    final Runtime r = Runtime.getRuntime();
    System.out.println("r.freeMemory() = " + r.freeMemory()/1024.0/1024);
    System.out.println("r.totalMemory() = " + r.totalMemory()/1024.0/1024);
    System.out.println("r.maxMemory() = " + r.maxMemory()/1024.0/1024);
    Thread.sleep(1000);
  }
}

Then I ran it with -Xmx100m, -Xmx110m, -Xmx120m, etc… for many many different values, both on Sun’s JVM and o JRockit. Sun’s will always report a bizarre value for maxMemory() and would grow on big steps (like 30M) between runs. JRockit reported the exact value every time.

  • 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-24T19:51:05+00:00Added an answer on May 24, 2026 at 7:51 pm


    The `Xms` and `Xmx` only serve to indicate the minimum and maximum sizes of the allocated heap. The actual size of the allocated heap could/will be a value between the minimum and maximum, as the JVM can resize the heap, especially during object allocation events or garbage collection events.

    If you need the JVM to use the "exact" heap size, you can specify Xms and Xmx values that are close enough to each other, so that heap resizing does not occur. Of course, these values must correspond to a contiguous amount of free memory.

    The above section assumed something else, and can be ignored for practical purposes.

    Based on the code used to calculate heap size, it should be noted that Runtime.maxMemory() returns a value that does not correspond to the value passed in the Xmx flag for the Hotspot JVM; the documentation is vague in stating that it will simply return a value that indicates the memory available for the JVM to use.

    Inferring from your posted code’s behavior, heap resizing will result in different values being reported for different invocations of Runtime.maxMemory(). Also, it would be needless to point out that the JRockit JVM reports the value passed in via Xmx flag.

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

Sidebar

Related Questions

When using Rails date_select with :prompt => true I see some very strange behavior
I see some strange behavior which I do not understand. I have a helper
I get some strange behavior when sorting a c++ vector with at custom comparator
I see some strange behavior in one of my UITableViewCell s. When setting the
I am struggling with some strange variable behavior in a recursive instance method. Running
I'm noticing some strange results with date conversions between MYSQL and PHP. Please see
I can see some potential difficulties with this concept but the idea is: I
I have some strange behavior occurring in an ASP.NET application that I am trying
I'm curious to see if anyone can shed some light on some strange text
Seeing some strange behavior, whereby connecting to Oracle database, and then calling external function,

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.