- 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).
- 零起點(diǎn)學(xué)Linux系統(tǒng)管理
- Linux從零開始學(xué)(視頻教學(xué)版)
- 無蘋果不生活 OS X Mountain Lion隨身寶典
- Linux網(wǎng)絡(luò)操作系統(tǒng)與實(shí)訓(xùn)(第三版)
- Windows Phone 7.5 Data Cookbook
- Mastering KVM Virtualization
- 計(jì)算機(jī)系統(tǒng)開發(fā)與優(yōu)化實(shí)戰(zhàn)
- 深入理解eBPF與可觀測(cè)性
- 8051軟核處理器設(shè)計(jì)實(shí)戰(zhàn)
- 巧學(xué)活用Windows 7
- 嵌入式實(shí)時(shí)操作系統(tǒng):RT-Thread設(shè)計(jì)與實(shí)現(xiàn)
- 寫給架構(gòu)師的Linux實(shí)踐:設(shè)計(jì)并實(shí)現(xiàn)基于Linux的IT解決方案
- Learn CUDA Programming
- 電腦辦公(Windows 10 + Office 2016)入門與提高(超值版)
- Windows Azure實(shí)戰(zhàn)