我试图弄清楚如何在客户端站点上安装的Windows服务器上删除jcmd.exe,以便我们可以解决堆和线程问题。真的不希望安装完整的JDK,因为它会使环境复杂化。
jcmd.exe肯定要运行JDK中的某些组件,但是我无法确定哪些组件。如果我可以将其分解为一个小的集合,然后将其解压缩到一个文件夹中,然后使用它来捕获数据,然后销毁它,那将是完美的。
有人知道jcmd需要运行哪些JDK组件吗?
最佳答案
快速检查jcmd.exe会发现:
ntdll.dll => /c/WINDOWS/SYSTEM32/ntdll.dll (0x7fff01820000)
KERNEL32.DLL => /c/WINDOWS/system32/KERNEL32.DLL (0x7ffeff180000)
KERNELBASE.dll => /c/WINDOWS/system32/KERNELBASE.dll (0x7ffefe810000)
SYSFER.DLL => /c/WINDOWS/System32/SYSFER.DLL (0x54f10000)
jli.dll => /c/apps/jdk1.8.0_121/bin/jli.dll (0x51ec0000)
MSVCR100.dll => /c/apps/jdk1.8.0_121/bin/MSVCR100.dll (0x51c40000)
ADVAPI32.dll => /c/WINDOWS/system32/ADVAPI32.dll (0x7ffefeeb0000)
msvcrt.dll => /c/WINDOWS/system32/msvcrt.dll (0x7fff01720000)
sechost.dll => /c/WINDOWS/system32/sechost.dll (0x7ffeff0c0000)
RPCRT4.dll => /c/WINDOWS/system32/RPCRT4.dll (0x7ffefec20000)
USER32.dll => /c/WINDOWS/system32/USER32.dll (0x7ffefef60000)
COMCTL32.dll => /c/WINDOWS/WinSxS/amd64_microsoft.windows.common-controls_6595b64144ccf1df_6.0.10586.672_none_a2d6b3cea53ff843/COMCTL32.dll (0x7ffef8460000)
GDI32.dll => /c/WINDOWS/system32/GDI32.dll (0x7ffeff230000)
combase.dll => /c/WINDOWS/system32/combase.dll (0x7ffeff3c0000)
bcryptPrimitives.dll => /c/WINDOWS/system32/bcryptPrimitives.dll (0x7ffefe540000)
因此看来,msvcr100.dll和jli.dll将是JDK中唯一必需的组件。超级快速的测试似乎表明这三个文件已足够,但是我承认我的测试情况可能并不完美。
编辑:经过进一步检查,这是我发现有效的最低配置。可能会稍微修改目录结构并设置诸如CLASSPATH,JAVA_HOME和PATH之类的内容。我没有探索所有排列。
.:
bin/ COPYRIGHT* jre/ lib/ LICENSE*
./bin:
jcmd.exe* jli.dll* msvcr100.dll*
./jre:
bin/ COPYRIGHT* lib/ LICENSE*
./jre/bin:
attach.dll* java.dll* jli.dll* net.dll* nio.dll* server/ unpack.dll*
verify.dll* zip.dll*
./jre/bin/server:
classes.jsa* jvm.dll* Xusage.txt*
./jre/lib:
amd64/ rt.jar*
./jre/lib/amd64:
jvm.cfg*
./lib:
jvm.lib* tools.jar*
我还离开了COPYRIGHT和LICENSE文件,因为它们很重要。
测试:
bin\jcmd.exe 16696 Thread.print
16696:
2017-04-27 18:01:49
Full thread dump Java HotSpot(TM) 64-Bit Server VM (25.121-b13 mixed mode):
"Worker-32" #84 prio=5 os_prio=0 tid=0x000000001bcaf800 nid=0x416c in
Object.wait() [0x00000000335ef000]
java.lang.Thread.State: TIMED_WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
at org.eclipse.core.internal.jobs.WorkerPool.sleep(WorkerPool.java:188)
- locked <0x00000000c21120a8> (a org.eclipse.core.internal.jobs.WorkerPool)
at org.eclipse.core.internal.jobs.WorkerPool.startJob(WorkerPool.java:220)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:52)
"Worker-31" #83 prio=5 os_prio=0 tid=0x000000001bcb7800 nid=0x315c in
Object.wait() [0x00000000312ef000]
java.lang.Thread.State: TIMED_WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
at org.eclipse.core.internal.jobs.WorkerPool.sleep(WorkerPool.java:188)
- locked <0x00000000c21120a8> (a org.eclipse.core.internal.jobs.WorkerPool)
at org.eclipse.core.internal.jobs.WorkerPool.startJob(WorkerPool.java:220)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:52)
<snip>...
F:\tmp\t1>bin\jcmd 16696 VM.flags
16696:
-XX:CICompilerCount=4 -XX:InitialHeapSize=268435456
-XX:MaxHeapSize=1073741824 -XX:MaxNewSize=357564416
-XX:MinHeapDeltaBytes=524288 -XX:NewSize=89128960 -XX:OldSize=179306496
-XX:+UseCompressedClassPointers -XX:+UseCompressedOops
-XX:+UseFastUnorderedTimeStamps -XX:-UseLargePagesIndividualAllocation
-XX:+UseParallelGC