Files
NoteBook/JVM/5. 命令行.md
T
2025-09-28 20:34:55 +08:00

40 lines
1.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 命令行
## jps
查看虚拟机进程
```sh
C:\Users\23117>jps -l
6048 org.jetbrains.jps.cmdline.Launcher
10372 sun.tools.jps.Jps
4228 cn.hezhaohui.app
9832 com.intellij.idea.Main
```
`jps -l` 命令列出的 Java 进程如下:
- `6048` - `org.jetbrains.jps.cmdline.Launcher`(JetBrains 项目构建工具)
- `10372` - `sun.tools.jps.Jps`(`jps` 自身进程)
- `4228` - `cn.hezhaohui.app`(自定义 Java 应用程序)
- `9832` - `com.intellij.idea.Main`(IntelliJ IDEA 主程序)
## jstats
```sh
C:\Users\23117>jstat -class -t 14988 1000 2
Timestamp Loaded Bytes Unloaded Bytes Time
57.7 902 2124.9 0 0.0 0.03
58.7 902 2124.9 0 0.0 0.03
```
`jstat -class -t 14988 1000 2` 的输出表示:
- **Timestamp**:时间戳(单位为秒)。
- **Loaded**:已加载的类数量(902 个)。
- **Bytes**:已加载类的总字节数(2124.9 KB)。
- **Unloaded**:已卸载的类数量(0 个)。
- **Bytes**:已卸载类的总字节数(0.0 KB)。
- **Time**:类加载/卸载所花费的时间(0.03 秒)。
此命令用于监控 Java 进程(PID 14988)的类加载统计信息,每秒输出一次,共输出 2 次。