简体   繁体   中英

memory swap to disk in Java JVM

I am using 64-bit Linux and Java JVM. I want to confirm if the memory used by JVM is smaller than physical memory size of the machine, there will be no disk memory swap by OS?

No, that's not necessarily true. Physical memory is shared by all processes, as well as by a bunch of other kernel things (eg the disk cache). So the amount of virtual memory used by your application is not the only consideration.

You can start your java application with the jvm argument -Xmx512m wich will tell the jvm to use a max of 512MB of ram for your heap. Take in account also that there exists another parameter for thread stack size -Xss512k. So the amount of memory that your jvm will use will be the max heap + (threadCount * threadStackSize) + some more ram for JIT compilation and GC datastructures depending on the GC collector that you use

Having this into account you can make sure your jvm wont use more ram than what is present in your machine

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM