[Java executable commands] (20) Heap dump snapshot file and heap information viewing tool jmap: generate multi-format heap dump files, print class loader information and view shared object mapping information ~

jmap of Java executable commands 1 concept 2 Advantages and disadvantages 3 use 3.1 Syntax format 3.2 Generating a heap dump file 3.3 Execute the jmap command to check the memory usage 3.4 Execute the jmap command to print object statistics 4 Application scenarios Summarize 1 concept jmap is a tool that comes with Java […]

Linux troubleshooting java cpu too high problem, JPS, JMAP, JSTAT, JSTACK and JCMD

code: [root@localhost cpu]# cat Test.java public class Test { public static void main(String[] args) { new Thread(()->{ System.out.println(“11111″); while(true) { } },”thread1”).start(); new Thread(()->{ System.out.println(“2222″); try { Thread. sleep(100000L); } catch (InterruptedException e) { throw new RuntimeException(e); } },”thread2”).start(); new Thread(()->{ System.out.println(“33333”); try { Thread. sleep(100000L); } catch (InterruptedException e) { throw new RuntimeException(e); } […]

Why implements Serializable? How to use jmap to view the heap in JVM?

Example A serialized object of User is defined here: Here is a test for writing to a file, that is, trying to serialize an object: java copy code @RestController public class TestController { @GetMapping(“/write”) public static void writeObj() { User user = new User(“sc”, 1); try { ObjectOutputStream objectOutputStream = new ObjectOutputStream(Files.newOutputStream(Paths.get(“/Users/suncong/Desktop/user.txt”))); objectOutputStream.writeObject(user); objectOutputStream. close(); […]

[Solved] The Java program does not have permission to access the Jmap solution in the docker container Operation not permitted

Attaching to process ID 8, please wait… Error attaching to process: sun.jvm.hotspot.debugger.DebuggerException: Can’t attach to the process: ptrace(PTRACE_ATTACH, ..) failed for 8: Operation not permitted sun.jvm.hotspot.debugger.DebuggerException: sun.jvm.hotspot.debugger.DebuggerException: Can’t attach to the process: ptrace(PTRACE_ATTACH, ..) failed for 8: Operation not permitted at sun.jvm.hotspot.debugger.linux.LinuxDebuggerLocal$LinuxDebuggerLocalWorkerThread.execute(LinuxDebuggerLocal.java:163) at sun.jvm.hotspot.debugger.linux.LinuxDebuggerLocal.attach(LinuxDebuggerLocal.java:278) at sun.jvm.hotspot.HotSpotAgent.attachDebugger(HotSpotAgent.java:671) at sun.jvm.hotspot.HotSpotAgent.setupDebuggerLinux(HotSpotAgent.java:611) at sun.jvm.hotspot.HotSpotAgent.setupDebugger(HotSpotAgent.java:337) at sun.jvm.hotspot.HotSpotAgent.go(HotSpotAgent.java:304) at sun.jvm.hotspot.HotSpotAgent.attach(HotSpotAgent.java:140) at […]

[Solved] jmap error in Docker: Can’t attach to the process: ptrace(PTRACE_ATTACH problem

Started a java service through docker. Log in to the container, view jvm related information through jmap, and report an error: # jmap -heap 6 Attaching to process ID 6, please wait… Error attaching to process: sun.jvm.hotspot.debugger.DebuggerException: Can’t attach to the process: ptrace(PTRACE_ATTACH, ..) failed for 6: Operation not permitted sun.jvm.hotspot.debugger.DebuggerException: sun.jvm.hotspot.debugger.DebuggerException: Can’t attach to […]