官术网_书友最值得收藏!

  • Java EE 8 High Performance
  • Romain Manni Bucau
  • 428字
  • 2021-06-30 19:14:31

Memory

The GC.class_histogram command allows you to get a heap histogram. We will deal with this in the coming sections. But just to sum up very quickly, the heap is where most of your Java objects will go. Therefore, it is important to see how it is used.

If we execute the GC.class_histogram command in our process, the output will look as follows:

$ jcmd 7577 GC.class_histogram
7577:

num #instances #bytes class name
----------------------------------------------
1: 192795 16202648 [C
2: 10490 4667040 [B
3: 191582 4597968 java.lang.String
4: 38779 3412552 java.lang.reflect.Method
5: 20107 2243296 java.lang.Class
6: 70045 2241440 java.util.HashMap$Node
7: 24429 2078312 [Ljava.util.HashMap$Node;
8: 47188 1887520 java.util.LinkedHashMap$Entry
9: 28134 1745104 [Ljava.lang.Object;
38: 2175 121800 com.sun.tools.javac.file.ZipFileIndex$DirectoryEntry
39: 1890 120960 com.mysql.jdbc.ConnectionPropertiesImpl$BooleanConnectionProperty
1739: 6 192 java.util.regex.Pattern$3
2357: 1 96 com.sun.crypto.provider.SunJCE
2478: 4 96 org.glassfish.jersey.server.AsyncContext$State
2548: 1 88 org.glassfish.ejb.startup.EjbDeployer
2558: 2 80 [Lcom.mysql.jdbc.StringUtils$SearchMode;
2649: 2 80 org.glassfish.kernel.embedded.EmbeddedDomainPersistence
2650: 2 80 org.glassfish.persistence.jpa.PersistenceUnitInfoImpl
2652: 1 80 org.hibernate.validator.internal.engine.ConfigurationImpl
2655: 5 80 org.jboss.weld.manager.BeanManagerImpl
2678: 1 72 [Lorg.glassfish.jersey.uri.UriComponent$Type;
2679: 2 72 [Lsun.security.jca.ProviderConfig;
2680: 1 72 com.github.rmannibucau.quote.manager.model.Quote
2689: 3 72 com.sun.enterprise.container.common.impl.ComponentEnvManagerImpl$FactoryForEntityManagerWrapper
2770: 3 72 org.eclipse.persistence.jpa.jpql.parser.TableExpressionFactory
6925: 1 16 sun.reflect.ReflectionFactory
Total 1241387 61027800

Here again, it is a partial output (truncated in multiple places) since it is too verbose for this book. If we find most of the environments we know, it is important to notice the following things:

  • com.mysql for the JDBC driver our application uses
  • com.github.rmannibucau for our application (the quote entity in particular)
  • com.sun.enterprise for the GlassFish server
  • org.jboss.weld for the CDI container of GlassFish
  • org.hibernate.validator for the GlassFish bean validation implementation
  • sun, com.sun, java, and so on for the JVM

Now, an important thing is to be able to interpret these figures. The first column is not very important but the next two are. As written in the table header, they represent the number of instances and their size in bytes.

If you run several concurrent requests on your server and filter the output for your quote entity, you can see the following:

 138:           591          42552  com.github.rmannibucau.quote.manager.model.Quote

This line means that the heap currently has 591 instances of Quote and it takes 42,552 bytes.

This means that it is a statistic you can check in real time while the server is running. But as it is written in the command help, it impacts the server (slows it down), so you need to use it for tuning purposes only.

The last interesting figure of the GC.class_histogram command is the total size of the heap, which is the last number printed. In our previous output, it was 61,027,800 bytes (about 61 MB).

主站蜘蛛池模板: 雅江县| 河南省| 永定县| 江口县| 晋江市| 集安市| 呼图壁县| 台湾省| 平南县| 扶余县| 玛多县| 宿松县| 靖边县| 牡丹江市| 积石山| 共和县| 舒兰市| 万山特区| 苏尼特右旗| 河东区| 新丰县| 阿勒泰市| 科技| 剑阁县| 都江堰市| 霸州市| 兴城市| 汉中市| 临漳县| 周口市| 清丰县| 图们市| 石楼县| 太原市| 深州市| 仙游县| 分宜县| 巴林左旗| 红桥区| 富川| 高雄市|