JVM server和client模式

本文介绍了Java虚拟机(JVM)中的两种运行模式:client模式和server模式,并详细解释了这两种模式的区别及其适用场景。此外,文章还提供了如何在不同操作系统中配置JVM模式的方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

命令行下输入:java -version


java version "1.7.0_45"
Java(TM) SE Runtime Environment (build 1.7.0_45-b18)
Java HotSpot(TM) 64-Bit Server VM (build 24.45-b08, mixed mode)


说明JVM是server模式,使用server模式的运行时编译器;也就是说还存在client模式与之对应,使用client模式的运行时编译器。client模式适合类似gui应用程序,server模式适合于后台型服务之类的程序。

配置在jvm.cfg文件里,64bit Mac下切换无用:
Windows, 路径:C:\Program Files\Java\jre1.5.0\lib\i386
Mac,路径:/Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk/Contents/Home/jre/lib


#
# Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
# ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
# List of JVMs that can be used as an option to java, javac, etc.
# Order is important -- first in this list is the default JVM.
# NOTE that this both this file and its format are UNSUPPORTED and
# WILL GO AWAY in a future release.
#
# You may also select a JVM in an arbitrary location with the
# "-XXaltjvm=<jvm_dir>" option, but that too is unsupported
# and may not be available in a future release.
#
-server KNOWN
-client IGNORE
-hotspot ERROR
-classic WARN
-native ERROR
-green ERROR

我的Mac上默认是server模式,无法修改,参考下面的引用问题2。64位版本里只有server模式。

具体可以参考[url=http://www.oracle.com/technetwork/java/hotspotfaq-138619.html#compiler_types]FAQ About the Java HotSpot VM[/url]

摘录比较重要的两点:
[b]JIT Compiler[/b]

[b]What's the difference between the -client and -server systems?[/b]

These two systems are different binaries. They are essentially two different compilers (JITs)interfacing to the same runtime system. The client system is optimal for applications which need fast startup times or small footprints, the server system is optimal for applications where the overall performance is most important. In general the client system is better suited for interactive applications such as GUIs. Some of the other differences include the compilation policy,heap defaults, and inlining policy.

[b]Where do I get the server and client systems?[/b]

Client and server systems are both downloaded with the 32-bit Solaris and Linux downloads. For 32-bit Windows, if you download the JRE, you get only the client, you'll need to download the SDK to get both systems.

For 64-bit, only the server system is included. On Solaris, the 64-bit JRE is an overlay on top of the 32-bit distribution. However, on Linux and Windows, it's a completely separate distribution.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值