Detailed explanation of the use of Java's jmap command

Introduction to the jmap command

jmap (Java Virtual Machine Memory Map) is a command-line tool provided by the JDK that can generate a heap dump snapshot dump file of the Java virtual machine. In addition, the jmap command can also view the details of the finalize execution queue, Java heap and method area, such as space usage, what garbage collector is currently in use, generational status, and so on.

Like the jinfo command, there are some limitations to its use on Windows systems. On dbgeng.dllWindows systems that don't have it, the debugging tools for Windows must be installed for the jinfo command to work, and the PATH environment variable should contain the location of jvm.dll.

jmap command parameters

Command syntax:

jmap [options] pid

Command parameter description:

  • option: Optional argument to the jmap command. If this parameter is not specified, the jinfo command will display the memory image information of the Java virtual machine process, as shown below:

Manneko Gakusha.png

  • pid: The process ID of the Java virtual machine for which configuration information is to be printed.

To get a list of running Java virtual machine processes, use the ps command (on Linux systems) or the tasklist command (on Windows systems), or if the Java virtual machine processes are not running in a separate docker instance, use the jps command.

optionWhat are the parameters? Let's take a look.

-heap

Displays the following information about the Java heap:

  • Information about the specified garbage collection algorithm, including the name of the garbage collection algorithm and details of the garbage collection algorithm.
  • Heap configuration information, which may be specified by command-line options, or selected by the Java virtual machine based on server configuration.
  • Memory space usage information of the heap, including generation, total capacity of each generation, used memory, and available memory. If a certain generation is further subdivided (eg, young generation), memory usage information for the subdivided space is included.

for example:

Manneko Gakusha

-histo[:live]

Displays statistics about objects in the Java heap, including: number of objects, memory size (in bytes), and fully qualified class name. for example:

Manneko Gakusha.png

To get the size of an object, divide its total size by the number of that object type. If the liveparameter is specified, only active objects are evaluated. for example:

Manneko Gakusha.png

-clstats

Displays statistics for class loaders in the metaspace in the Java heap, including:

class_loader: the address of the class loader object when the Java virtual machine is running classes: the number of loaded classes bytes: the number of bytes occupied by the metadata of all classes loaded by the class loader parent_loader: the address of the parent class loader object , if not shown null. alive: The identifier of whether the class loader is alive or not, indicating whether the class loader object will be garbage collected. type: The class name of this class loader.

for example:

Manneko Gakusha.png

-finalizerinfo

Displays objects in the F-Queue waiting for the Finalizer thread to execute the finalize method. for example:

Manneko Gakusha.png

-dump:[live,]format=b,file=<filename>

Generate a heap dump snapshot dump file of the Java virtual machine. The specific instructions are as follows:

  • liveThe argument is optional, if specified, only live objects in the heap are dumped; if not specified, all objects in the heap are dumped.
  • format=bRepresents a memory dump of the Java heap in hprof binary format.
  • file=<filename>Used to specify the filename of the snapshot dump file.

for example:

Manneko Gakusha.png

-F

Mandatory mode. -dumpCan be used in conjunction or -histotogether if the specified pid does not respond . In this mode, the live parameter is not supported. for example:

Manneko Gakusha.png

-h and -help

Displays help information for the jinfo command.

Finally, thank you for being so handsome, and for giving me likes and attention .

{{o.name}}
{{m.name}}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324134328&siteId=291194637