- 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).
- 30天自制操作系統
- Citrix XenApp Performance Essentials
- Linux運維實戰:CentOS7.6操作系統從入門到精通
- 大學計算機應用基礎實踐教程(Windows 7+Office 2013)
- 玩到極致 iPhone 4S完全攻略
- 計算機系統開發與優化實戰
- 8051軟核處理器設計實戰
- 直播系統開發:基于Nginx與Nginx-rtmp-module
- 無蘋果不生活 The New iPad隨身寶典
- Learning Magento 2 Administration
- AutoCAD 2014中文版從入門到精通
- Mastering Reactive JavaScript
- 統信UOS應用開發進階教程
- 15分鐘!畫出我的漫畫角色:賣萌篇
- 樹莓派+傳感器:創建智能交互項目的實用方法、工具及最佳實踐