Windows 使用jmap: Error attaching to process: Windbg Error: GetModuleParameters failed!

1.使用开发工具Eclipse启动web工程,使用jmap PID 报错。

C:\Users\Lenovo>jps
15760 RemoteMavenServer36
19312
16228 jar
17876 KotlinCompileDaemon
17908 Launcher
10360 jar
10044 Main
13052 KotlinCompileDaemon
18860 Jps

C:\Users\Lenovo>jmap 10360
Attaching to process ID 10360, please wait...
Error attaching to process: Windbg Error: GetModuleParameters failed!
sun.jvm.hotspot.debugger.DebuggerException: Windbg Error: GetModuleParameters failed!
        at sun.jvm.hotspot.debugger.windbg.WindbgDebuggerLocal.attach0(Native Method)
        at sun.jvm.hotspot.debugger.windbg.WindbgDebuggerLocal.attach(WindbgDebuggerLocal.java:152)
        at sun.jvm.hotspot.HotSpotAgent.attachDebugger(HotSpotAgent.java:671)
        at sun.jvm.hotspot.HotSpotAgent.setupDebuggerWin32(HotSpotAgent.java:569)
        at sun.jvm.hotspot.HotSpotAgent.setupDebugger(HotSpotAgent.java:335)
        at sun.jvm.hotspot.HotSpotAgent.go(HotSpotAgent.java:304)
        at sun.jvm.hotspot.HotSpotAgent.attach(HotSpotAgent.java:140)
        at sun.jvm.hotspot.tools.Tool.start(Tool.java:185)
        at sun.jvm.hotspot.tools.Tool.execute(Tool.java:118)
        at sun.jvm.hotspot.tools.PMap.main(PMap.java:72)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at sun.tools.jmap.JMap.runTool(JMap.java:201)
        at sun.tools.jmap.JMap.main(JMap.java:130)

解决方法:
1.将运行在Eclipse,Idea。打包成.jar文件
2.使用java -jar xxxx.jar 运行程序
3.jps 查询java进程获取 PID
4.jmap PID

C:\Users\Lenovo>jmap -heap 10360
Attaching to process ID 16228, please wait...
Debugger attached successfully.
Client compiler detected.
JVM version is 25.131-b11

using thread-local object allocation.
Mark Sweep Compact GC

Heap Configuration:
   MinHeapFreeRatio         = 40
   MaxHeapFreeRatio         = 70
   MaxHeapSize              = 268435456 (256.0MB)
   NewSize                  = 5570560 (5.3125MB)
   MaxNewSize               = 89456640 (85.3125MB)
   OldSize                  = 11206656 (10.6875MB)
   NewRatio                 = 2
   SurvivorRatio            = 8
   MetaspaceSize            = 12582912 (12.0MB)
   CompressedClassSpaceSize = 1073741824 (1024.0MB)
   MaxMetaspaceSize         = 4294901760 (4095.9375MB)
   G1HeapRegionSize         = 0 (0.0MB)

Heap Usage:
New Generation (Eden + 1 Survivor Space):
   capacity = 5373952 (5.125MB)
   used     = 4152464 (3.9600982666015625MB)
   free     = 1221488 (1.1649017333984375MB)
   77.2702100800305% used
Eden Space:
   capacity = 4784128 (4.5625MB)
   used     = 3689400 (3.5184860229492188MB)
   free     = 1094728 (1.0440139770507812MB)
   77.11750187285959% used
From Space:
   capacity = 589824 (0.5625MB)
   used     = 463064 (0.44161224365234375MB)
   free     = 126760 (0.12088775634765625MB)
   78.50884331597223% used
To Space:
   capacity = 589824 (0.5625MB)
   used     = 0 (0.0MB)
   free     = 589824 (0.5625MB)
   0.0% used
tenured generation:
   capacity = 11833344 (11.28515625MB)
   used     = 10479408 (9.993942260742188MB)
   free     = 1353936 (1.2912139892578125MB)
   88.55829763759087% used

12037 interned Strings occupying 947544 bytes.

原因:
服务启动的jdk和jmap -heap时使用的jdk对应不上(一个是32位,一个是64位

你可能感兴趣的:(操作系统,jvm)