0

我正在学习一些 JVM 工具,如 jstat、jmap、jtack 等。当我输入jstat命令行时,它会响应以下消息:

Usage:
    jmap [option] <pid>
        (to connect to running process)
    jmap [option] <executable <core>
        (to connect to a core file)
    jmap [option] [server_id@]<remote server IP or hostname>
        (to connect to remote debug server)

where <option> is one of:
    <none>               to print same info as Solaris pmap
    -heap                to print java heap summary
    -histo[:live]        to print histogram of java object heap; if the "live"
                         suboption is specified, only count live objects
    -permstat            to print permanent generation statistics
    -finalizerinfo       to print information on objects awaiting finalization
    -dump:<dump-options> to dump java heap in hprof binary format
                         dump-options:
                           live         dump only live objects; if not specified,
                                        all objects in the heap are dumped.
                           format=b     binary format
                           file=<file>  dump heap to <file>
                         Example: jmap -dump:live,format=b,file=heap.bin <pid>
    -F                   force. Use with -dump:<dump-options> <pid> or -histo
                         to force a heap dump or histogram when <pid> does not
                         respond. The "live" suboption is not supported
                         in this mode.
    -h | -help           to print this help message
    -J<flag>             to pass <flag> directly to the runtime system

问题是我对选项-J 感到困惑。

-J<flag>             to pass <flag> directly to the runtime system

当我输入jstat -J-version时,它说

java version "1.6.0_22"
Java(TM) SE Runtime Environment (build 1.6.0_22-b04)
Java HotSpot(TM) 64-Bit Server VM (build 17.1-b03, mixed mode)

此选项用于什么以及“标志”的确切含义是什么?

4

2 回答 2

4

Oracle 在线文档关于jstat更清楚:

-JjavaOption

将 javaOption 传递给 Java 应用程序启动器。例如,-J-Xms48m 将启动内存设置为 48 MB。有关选项的完整列表,请参阅 java(1)。

此选项用于将 Java 选项传递给运行时 JRE,例如设置内存大小。可以在此处查看可能的选项列表。

于 2015-09-11T08:08:53.237 回答
2

这意味着它将该标志传递给 jstat 调用的子 JVM 进程。

例如,jstat -J-version有效地调用:

java -version

它具有打印出JVM版本的效果。

于 2015-09-11T08:08:24.120 回答