在 Java JVM 中将内存交换到磁盘 [英] memory swap to disk in Java JVM

查看:93
本文介绍了在 Java JVM 中将内存交换到磁盘的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是 64 位 Linux 和 Java JVM.我想确认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?

推荐答案

您可以使用 jvm 参数 -Xmx512m 启动您的 Java 应用程序,这将告诉 jvm 为您的堆使用最大 512MB 的 ram.还要考虑到线程堆栈大小 -Xss512k 还存在另一个参数.因此,您的 jvm 将使用的内存量将是最大堆 + (threadCount * threadStackSize) + 一些用于 JIT 编译和 GC 数据结构的内存,具体取决于您使用的 GC 收集器

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

考虑到这一点,您可以确保您的 jvm 不会使用比您机器中现有的更多的内存

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

这篇关于在 Java JVM 中将内存交换到磁盘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆