我有一个Java程序,我使用jps运行并找到了它的进程ID。
如何查看此Java进程的-Xms和-Xmx变量的值?
尝试
jcmd <PID> VM.command_line
jcmd <PID> VM.flags
JAVA_OPTS
。请尝试使用_JAVA_OPTIONS
。 - apanginjps # shows pids
jps -v <pid> # shows params
jps -v <localhost:pid> # the host must be indicated
Runtime.getRuntime().maxMemory()
您可以使用类MemoryUsage获取内存管理的初始值、已使用量和最大可用量。
MemoryMXBean memoryBean = ManagementFactory.getMemoryMXBean();
memoryBean.getHeapMemoryUsage().getMax()
memoryBean.getHeapMemoryUsage().getUsed()
memoryBean.getHeapMemoryUsage().getInit()
jps -lvm
。 - Peter Lawreyjmap
命令可以给你想要的所有信息。root@BobServerStation:/usr/local $ jmap -heap 3280
Attaching to process ID 3280, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 24.65-b04
using thread-local object allocation.
Parallel GC with 8 thread(s)
Heap Configuration:
MinHeapFreeRatio = 0
MaxHeapFreeRatio = 100
MaxHeapSize = 4116709376 (3926.0MB)
NewSize = 1310720 (1.25MB)
MaxNewSize = 17592186044415 MB
OldSize = 5439488 (5.1875MB)
NewRatio = 2
SurvivorRatio = 8
PermSize = 21757952 (20.75MB)
MaxPermSize = 85983232 (82.0MB)
G1HeapRegionSize = 0 (0.0MB)
Heap Usage:
PS Young Generation
Eden Space:
capacity = 65011712 (62.0MB)
used = 42273152 (40.3148193359375MB)
free = 22738560 (21.6851806640625MB)
65.0239021547379% used
From Space:
capacity = 10485760 (10.0MB)
used = 10479760 (9.994277954101562MB)
free = 6000 (0.0057220458984375MB)
99.94277954101562% used
To Space:
capacity = 10485760 (10.0MB)
used = 0 (0.0MB)
free = 10485760 (10.0MB)
0.0% used
PS Old Generation
capacity = 171442176 (163.5MB)
used = 376368 (0.3589324951171875MB)
free = 171065808 (163.1410675048828MB)
0.21953057805332568% used
PS Perm Generation
capacity = 22020096 (21.0MB)
used = 15401488 (14.688003540039062MB)
free = 6618608 (6.3119964599609375MB)
69.94287400018601% used
8464 interned Strings occupying 699456 bytes.
sudo jmap -heap {pid}
@Adon Smith - Hunter Zhao
jps
。你能否在你的问题中添加以下信息:(1)哪个MacOS X版本。(2)哪个Java版本。(3)运行which jps
的结果。(4)运行file $(which jps)
的结果。 - RealSkeptic