Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use the jmap command of Java

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article will explain in detail how to use the jmap command about Java. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.

Introduction to jmap command

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

Like the jinfo command, there are some restrictions on using it on Windows systems. On Windows systems without dbgeng.dll, debugging tools for Windows must be installed for the jinfo command to work properly, and the PATH environment variable should contain the location of the jvm.dll.

Jmap command parameters

Command syntax:

Jmap [options] pid

The command parameter description:

Optional parameters for the option:jmap command. If this parameter is not specified, the jinfo command displays the memory image information of the Java virtual machine process, as shown in the following figure:

Pid: the process ID of the Java virtual machine to print configuration information.

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

What are the parameters of option? Let's take a look.

-heap

Displays the following information for the Java heap:

Information about the specified garbage collection algorithm, including the name and details of the garbage collection algorithm.

The configuration information for the heap may be specified by the command line option or selected by the Java virtual machine based on the server configuration.

Memory space usage information of the heap, including generation, total capacity of each generation, memory used, memory available. If a generation is continued to be subdivided (for example, the younger generation), it contains memory usage information for the subdivided space.

For example:

-histo [: live]

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

To get the size of an object, you can divide its total size by the number of that object type. If the live parameter is specified, only the active object is evaluated. For example:

-clstats

Displays statistics for classloaders for metaspaces in the Java heap, including:

Class_loader: the address of the classloader object when the Java virtual machine is running

Classes: number of loaded classes

Bytes: the number of bytes of metadata for all classes loaded by this class loader

Parent_loader: the address of the parent class loader object, if null is not displayed.

Alive: an indication of whether the classloader object will be garbage collected.

Type: the class name of this class loader.

For example:

-finalizerinfo

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

-dump: [live,] format=b,file=

Generate a heap dump snapshot dump file for the Java virtual machine. The details are as follows:

The live parameter is optional, and if specified, only the active objects in the heap are dumped; if not specified, all objects in the heap are dumped.

Format=b represents memory that dumps the Java heap in hprof binary format.

File= is used to specify the file name of the snapshot dump file.

For example:

-F

Mandatory mode. If the specified pid does not respond, it can be used with-dump or-histo. The live parameter is not supported in this mode. For example:

-h and-help

Displays help information for the jinfo command.

This is the end of the article on "how to use the jmap command of Java". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report