Jvm heap configuration template

Greetings to all, I observed when setting up the heap size, people prefer the values ​​64,128,256,1024 ... If I give a value between these numbers (say 500), will jvm not accept this value? Why are these numbers important and preferred? Why are we also updating RAM in this template.

Please help me understand.

Thanks in advance, Habin

+5
source share
5 answers

JVM will take on any value, no problem. Using values ​​of 2 ^ n is just a “convention”, using others will not have a negative effect in practice.

+4
source

Well, if you think of it this way:

  • 1 byte - 8 bits

  • 1 kb = 1024 bytes

  • 1 mb = 1024 kb

  • 1 gb = 1024 mb

  • ... etc...

2^n. - , .

, , - . - "" 2, .. 1, 2, 4, 8, 16, 32.... ( , ( , )). , 4 (nybble ) 2 ^ 4 16 . , 2, 8 ( 256 ) .

, ( , 7 9). , . , , , , , .

, 8 , ( ..) , 7-8 ( ).

+2

, , megabytes (M m) gigabytes ( G g) .

: java -Xms500M -Xmx500M -jar myJavaProgram.jar

, .

0

.

This is because memory chips / cards / have sizes that have a capacity of 2 bytes. And the main reason for this is that it simplifies the electronics. And simpler - cheaper, more reliable and (possibly) faster.

0
source

Besides the unwritten agreement, it also affects performance - depending on the architecture of the machine.

For example, if a machine is based on a triple basis, it will work better if the heap size is set to 3.

0
source

All Articles