Why do JVM memory parameters usually have a multiplicity of 256?

I saw almost all the JVM memory options, usually in the binary value of 256 or round - for example. 256 m, 512 m, 1024 m, etc. I know this may be due to the fact that physical memory (RAM) is usually a binary number, for example 256 MB, 1 GB, etc.

My question is, does this really help memory management if the JVM memory is set to a multiple of 256 or any binary value? Does the JVM memory want to have a rounded decimal value, for example 1000 m, instead of 1024 m, although I have never seen a JVM using a value that is considered round in terms of a decimal number.

The OS will allocate the mentioned JVM memory when it starts, so I think this is more of a question for the JVM, can it effectively manage the size of the rounded decimal memory (for example, 1000 MB) or will there be any flaws.

EDIT: I know we CAN use decimal values ​​for JVM memory, but my question is SHOULD do we use decimal values?

EDIT2: For opinions / suggestions that the JVM is equally efficient at processing each memory size, please share any relevant links that you used to get this output. I have seen enough WAR on this topic among other developers, but I have not seen many specific arguments to answer either a decimal or a binary value.

+5
source share
5 answers

There is no need to use a multiple of 2 for JVM memory parameters. For memory allocation, a double value is simply used if the old is not enough.

If you increase the set memory value in 1 MB steps, you will need to adjust the value several (hundreds) times before the configuration meets your requirements. Thus, it is more comfortable to double the old value.

It depends on the fact that memory is a cheap resource in those days.

EDIT:

As already mentioned, values ​​such as 1000 MB or 381 MB can be assigned. The JVM can handle every memory size that is large enough to accommodate permGenSpace, the stack and the heap.

+6
source

There is no real requirement that these values ​​be multiplier 2. This is just a way to use it. you can use what is ever appreciated there.

 -Xms1303m -Xmx2303m -XX:MaxPermSize=256m // my configs 
0
source

This is just a way to ensure that the size you specify (as an argument) matches the actual allocated memory, as the machine allocates memory in blocks of size 2.

0
source

It does not matter. There is no special treatment for round values.

You can specify the memory size within 1-byte precision - the JVM itself will be rounded to a size convenient for it. For instance. heap size is rounded to the border of 2 MB. See my other answer: fooobar.com/questions/1200107 / ...

0
source

I think this is basically a way of thinking, something like: I have 1 GB of memory, I will give the JVM half, that is 512 MB.

0
source

Source: https://habr.com/ru/post/1200105/


All Articles