In general, I have a file running main.jar, I need to dump it to a file, there is a command:

jmap -F -dump <file> <pid> 

but it does not work correctly (displays an attachment error). How to call this command?

  • Can you see exactly the command that you run and the full text of the error? - Sergey Gornostaev
  • jmap -dump: format = b, file = cheap.bin pid screenshot.ru/8a86851f7a30ffc49083bf650f89a84e.png - JuniorD
  • It seems that main.jar is running under JVM version 1.5 or lower. Try using JVM version 1.6 or higher to run main.jar. - Ilya
  • Not much on the subject matter. Convenient Java VisualVM graphical tools (starting with JDK 6u7) and Java Mission Control (starting with JDK 7u40) exist for monitoring the JVM - Ilya
  • @Ilya main.jar was launched under JRE v8, but the JDK is my v7 u67. Once I heard on one forum that "Java 6 is generally easy to dump" is this true? - JuniorD

1 answer 1

Many of the jdk tula with the -F flag use the serviceability of the agent, without one tricky property, it will fall if the jvm versions (up to the build versions) do not match. This refers to the jvm version of the target process and which starts the agent. Try without this flag, in this case the dynamic attach api will be used.