---
title: "Java虚拟机（JVM）参数配置说明"
author: "softtian1983"
date: "2008-04-12T15:51:37Z"
tags: []
slug: "java-jvm"
draft: false
lastmod: "2008-04-12T15:51:37Z"
id: 182122
url: "https://twb.iteye.com/blog/182122"
---

查看JVM参数

开始—&gt;运行输入cmd

java -X (区分大小写)

1、-Xmixed mixed mode execution (default)  
   混合[**模式**]()执行(默认)

2、-Xint interpreted mode execution only  
解释模式执行

3、-Xbootclasspath:  
set search path for bootstrap classes and resources  
设置zip/jar资源或者类（.class文件）存放目录路径

3、-Xbootclasspath/a:  
append to end of bootstrap class path  
追加zip/jar资源或者类（.class文件）存放目录路径

4、-Xbootclasspath/p:  
prepend in front of bootstrap class path  
预先加载zip/jar资源或者类（.class文件）存放目录路径

5、-Xnoclassgc disable class garbage collection  
关闭类垃圾回收功能

6、-Xincgc enable incremental garbage collection  
开启类的垃圾回收功能

7、-Xloggc:log GC status to a file with time stamps  
记录垃圾回日志到一个[**文件**]()。

8、-Xbatch disable background compilation  
关闭后台[**编译**]()

9、-Xms set initial Java heap size  
设置JVM初始化堆[**内存**]()大小

10、-Xmx set maximum Java heap size  
设置JVM最大的堆内存大小

11、-Xss set java thread stack size  
设置JVM栈内存大小

12、-Xprof  output cpu profiling data  
输入CPU概要表数据

13、-Xfuture enable strictest checks, anticipating future default  
执行严格的代码检查，预测可能出现的情况

14、-Xrs reduce use of OS signals by Java/VM (see documentation)  
通过JVM还原操作系统信号

15、-Xcheck:jni  perform additional checks for JNI functions  
对JNI函数执行检查

16、-Xshare:off  do not attempt to use shared class data  
尽可能不去使用共享类的数据

17、-Xshare:auto  use shared class data if possible (default)  
尽可能的使用共享类的数据

18、-Xshare:on  require using shared class data, otherwise fail.  
尽可能的使用共享类的数据，否则运行失败

The -X options are non-standard and subject to change without notice.

一般设置：

设置服务器端的 JVM:JAVA\_OPTS="-server -Xms1000m -Xmx1000m -Xss512k"

-server:一定要作为第一个参数，在多个CPU时性能佳

-Xms：初始Heap大小，使用的最小内存

-Xmx：java heap最大值，使用的最大内存

上面两个值一般设置为同样的大小。

-Xss：每个线程的Stack大小

-verbose:gc 现实垃圾收集信息

-Xloggc:gc.log 指定垃圾收集日志文件

-Xmn：young generation的heap大小，一般设置为Xmx的3、4分之一

-XX:+UseParNewGC ：缩短minor收集的时间

-XX:+UseConcMarkSweepGC ：缩短major收集的时间

提示：此选项在Heap Size 比较大而且Major收集时间较长的情况下使用更合适