Java Memory Limit -Xmx suffix: upper vs lower case m/M and g/G

27,428

Solution 1

There is no difference between k and K both means kibibyte and so does m/M = mebibyte & g/G = gibibyte. you can set 100m as the value and it will be 100 * 1024 * 1024 bytes. generally it is advised to use this value in powers of 2.

Hope it helps.

Solution 2

Why don't you just try -Xmx100m and -Xmx100M and check if there is any difference.
k, m, g work exactly like K, M, G - they all mean binary units.

Solution 3

All memory sizes used by the JVM command line arguments are specified in binary units (Kibibyte, Mebibyte, etc.) regardless of unit capitalization; where a 'kilobyte' is 1024 bytes, and the others are increasing powers of 1024.

This answer goes into a more complete technical answer to the question.

Share:
27,428
MinecraftShamrock
Author by

MinecraftShamrock

Updated on July 27, 2022

Comments

  • MinecraftShamrock
    MinecraftShamrock almost 2 years

    It is commonly known that it is possible to limit the Java heap size with -Xmx<amount><unit>, where unit is the data amount unit like Gigabyte, Megabyte, etc. I know that -Xmx128M means 128 Mebibytes (= 128 * 1024 * 1024 bytes).

    But is it true, that it is also possible to use decimal units like megabytes using -Xmx100m (which would be 100 * 1000 * 1000 bytes)?

    So is it possible to use this decimal units by using lower-case unit suffixes like k, m, g instead of K, M, G?