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

What are GC and GC Tuning?

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article introduces the relevant knowledge of "what is GC and GC Tuning". In the operation of actual cases, many people will encounter such a dilemma. Then let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Basic knowledge of GC and GC TuningGC 1. What is garbage?

C language application memory: malloc free

Caterpillar: new delete

CMB + manually reclaim memory

Java: new?

Automatic memory collection, programming is simple, the system is not prone to errors, manual release of memory, prone to two types of problems:

Forget to recycle

Multiple recovery

One or more objects (circular references) that are not pointed to by any reference

two。 How to locate garbage

Reference count (ReferenceCount)

Root reachability algorithm (RootSearching)

3. Common garbage collection algorithms

Mark removal (mark sweep)-fragmentation caused by discontinuous locations is inefficient (two-pass scan)

Copy algorithm (copying)-No fragmentation, waste of space

Mark compression (mark compact)-No fragmentation, low efficiency (two scans, pointer needs to be adjusted)

4.JVM memory generation model (for generational garbage collection algorithms)

Models used by some garbage collectors

All GC except Epsilon ZGC Shenandoah use logical generational model.

G1 is logical generation, but physical generation is not.

In addition, not only logical generation, but also physical generation

Cenozoic + old age + permanent generation (1.7) Perm Generation/ metadata area (1.8) Metaspace

Permanent generation metadata-Class

The permanent generation must specify a size limit, metadata can be set or not set, and there is no upper limit (limited to physical memory)

String constant 1.7-permanent, 1.8-heap

MethodArea logical concepts-permanent generation, metadata

Cenozoic = Eden + 2 suvivor regions

After YGC recycling, most of the objects will be recycled and will enter S0 alive

YGC again, the living object eden + S0-> S1

YGC,eden + S1-> S0 again

Old enough-> Old Age (15 CMS 6)

S area doesn't fit-> old age.

Old age

Diehard element

The old age is full of FGC Full GC.

GC Tuning (Generation)

Minimize FGC

MinorGC = YGC

MajorGC = FGC

Object allocation process diagram

Dynamic age: (unimportant) https://www.jianshu.com/p/989d3b06a49d

Allocation guarantee: (not important) there is not enough space in the survivor area during the YGC period to guarantee a direct entry into the old age reference: https://cloud.tencent.com/developer/article/1082730

5. Common garbage collector

JDK was born, Serial followed to improve efficiency, and PS was born. In order to cooperate with CMS, PN,CMS was introduced at the end of version 1.4. CMS is a landmark GC, which starts the process of concurrent recycling, but there are many problems with CMS, so at present, any version of JDK defaults to CMS concurrent garbage collection because it can't stand STW.

Serial Young Generation Serial Recycling

PS young generation parallel recycling

The young generation of ParNew cooperates with the parallel recycling of CMS

SerialOld

ParallelOld

ConcurrentMarkSweep concurrency in the old years, garbage collection and applications run at the same time, reducing the time of STW (200ms) CMS problems are more, so now there is not a default version of CMS, can only manually specify that since CMS is MarkSweep, there must be fragmentation problems, fragments to a certain extent, when the old age of CMS allocation objects can not be allocated Use SerialOld for old-age recycling imagine: PS + PO-> add memory for garbage collector-> PN + CMS + SerialOld (STW for a few hours-days) dozens of gigabytes of memory, single-thread recycling-> G1 + FGC dozens of G-> server ZGC algorithm for T memory: tricolor tag + Incremental Update

G1 (10ms) algorithm: tricolor tag + SATB

ZGC (1ms) competitive C++ algorithm: ColoredPointers + LoadBarrier

Shenandoah algorithm: ColoredPointers + WriteBarrier

Eplison

An extension of the difference between PS and PN: click

The relationship between garbage collector and memory size

Serial tens of megabytes

PS hundreds of megabytes-several gigabytes

CMS-20g

G1-hundreds of GB

ZGC-4T-16T (JDK13)

Default garbage collection: PS + ParallelOld

Common garbage collector combination parameter setting: (1.8)

-XX:+UseSerialGC = Serial New (DefNew) + Serial Old

Mini programs. This option is not available by default, and HotSpot automatically selects the collector based on the calculation and configuration and the JDK version

-XX:+UseParNewGC = ParNew + SerialOld

This combination is rarely used (obsolete in some versions)

Https://stackoverflow.com/questions/34962257/why-remove-support-for-parnewserialold-anddefnewcms-in-the-future

-XX:+UseConcMarkSweepGC = ParNew + CMS + Serial Old

-XX:+UseParallelGC = Parallel Scavenge + Parallel Old (1.8 default) [PS + SerialOld]

-XX:+UseParallelOldGC = Parallel Scavenge + ParallelOld

-XX:+UseG1GC = G1

No way to view the default GC is found in Linux, but UseParallelGC is printed in windows

Java + XX:+PrintCommandLineFlags-version

Tell the difference by GC's log

What exactly is the default garbage collector for version 1.8 of Linux?

1.8.0x181 default (invisible) Copy MarkCompact

1.8.00222default PS + PO

The first step of JVM tuning is to understand the common command line parameters of JVM

Command line parameter reference for JVM

HotSpot parameter classification

Standard:-beginning, all HotSpot supports non-standard:-X start, specific version HotSpot supports specific command instability:-XX start, the next version may be canceled

Java-version java-X test program:

Import java.util.List;import java.util.LinkedList;public class HelloGC {public static void main (String [] args) {System.out.println ("HelloGC!"); List list = new LinkedList (); for (;;) {byte [] b = new byte [1024x1024]; list.add (b);}

Distinguishing concepts: memory leak memory leak, memory overflow out of memory

Java-XX:+PrintCommandLineFlags HelloGC

Java-Xmn10M-Xms40M-Xmx60M-XX:+PrintCommandLineFlags-XX:+PrintGC HelloGC PrintGCDetails PrintGCTimeStamps PrintGCCauses

Java-XX:+UseConcMarkSweepGC-XX:+PrintCommandLineFlags HelloGC

Java-XX:+PrintFlagsInitial default parameter valu

Java-XX:+PrintFlagsFinal final parameter value

Java-XX:+PrintFlagsFinal | grep xxx finds the corresponding parameter

Java-XX:+PrintFlagsFinal-version | grep GC

Detailed explanation of PS GC log

The log format for each garbage collector is different!

PS log format

Heap dump section:

The memory address after eden space 5632K, 94% used [0x00000000ff980000.0x00000000ffeb3e28recover0x00000000fff00000) refers to the starting address, using the space end address, and the overall space end address.

Total = eden + 1 survivor (because survivor is a replication algorithm, the actual free space can only be 1 survivor)

Basic concepts before tuning:

Throughput: user code time / (user code execution time + garbage collection time)

Response time: the shorter the STW, the better the response time

The so-called tuning, the first to determine, what to pursue? Throughput priority or response time priority? Or in the case of meeting a certain response time, how much throughput is required.

Problem: scientific calculation, throughput. Data mining, thrput. General throughput priority: (PS + PO) response time: website GUI API (1.8G1)

What is tuning?

JVM planning and pre-tuning according to demand

Optimize the running environment of JVM (slow, stutter)

Solve all kinds of problems during the operation of JVM (OOM)

Tuning, starting with planning

Tuning, starting with business scenarios, tuning without business scenarios is hooliganism.

No monitoring (stress test, you can see the results), no tuning

Steps:

-Xloggc:/opt/xxx/logs/xxx-xxx-gc-%t.log-XX:+UseGCLogFileRotation-XX:NumberOfGCLogFiles=5-XX:GCLogFileSize=20M-XX:+PrintGCDetails-XX:+PrintGCDateStamps-XX:+PrintGCCause

Or generate a log file every day

Response time, pause time [CMS G1 ZGC] (need to respond to the user)

Throughput = user time / (user time + GC time) [PS]

Familiar with business scenarios (there is no best garbage collector, only the most suitable garbage collector)

Select recycler combination

Calculate memory requirements (experience 1.5G 16G)

Select CPU (as high as possible)

Set the age and upgrade age

Set log parameters

Observe the log

Case 1: vertical e-commerce, up to millions of orders per day, what kind of server configuration is required for the order processing system?

This problem is amateur, because many different server configurations can support (1.5G 16G)

360000 orders / second, (find the peak within one hour, 1000 orders / second)

Empirical value

Have to calculate: how much memory does it take to generate an order? 512K * 1000 500m memory

Ask professionally: request response time 100ms

Stress test!

Case 2: how to support the large-scale ticket grabbing during the Spring Festival in case 2?

12306 should be the website with the largest number of concurrency in China:

The so-called concurrency is 100W, the highest.

CDN-> LVS-> NGINX-> Business system-> 1W concurrency per machine (10K problem) 100machines

General e-commerce order-> place order-> order system (IO) reduce inventory-> wait for user to pay

A possible model of 12306: place order-> reduce inventory and order (redis kafka) at the same time asynchronously-> etc. Payment

Inventory reduction will eventually put pressure on a server.

Can do distributed local inventory + individual server to do inventory balance

The method of dealing with large flow: divide and conquer

How much memory does it consume to get a transaction?

Get a machine and see how much TPS it can withstand? Did you achieve the goal? Expand or tune to achieve

Determine by pressure test

Optimize the environment

There is a 500000 PV data website (extracting documents from disk to memory). The original server is 32-bit, 1.5 GB heap, and the user feedback website is relatively slow, so the company decided to upgrade the new server to 64-bit, 16-gigabyte heap memory. as a result, the user feedback stutter is very serious, but less efficient than before.

Why is the original website slow? Many users browse data, a lot of data load to memory, lack of memory, frequent GC,STW is long, response time becomes slow

Why is it more stuttered? The larger the memory, the longer the FGC time

What are we going to do? PS-> PN + CMS or G1

The system CPU is often 100%. How to tune it? (high frequency of interview) CPU100%, then there must be threads taking up system resources.

Find out which process has the highest cpu (top)

Which thread in this process has a high cpu (top-Hp)

Export the thread's stack (jstack)

Find out which method (stack frame) consumes time (jstack)

High proportion of worker threads | High proportion of garbage collection threads

The memory of the system is high, how to find the problem? (high frequency of interview)

Export heap memory (jmap)

Analysis (jhat jvisualvm mat jprofiler...)

How to monitor JVM

Jstat jvisualvm jprofiler arthas top...

Solving the problems in the Operation of JVM A case study of Common tools

Test the code:

Package com.test.jvm.gc;import java.math.BigDecimal;import java.util.ArrayList;import java.util.Date;import java.util.List;import java.util.concurrent.ScheduledThreadPoolExecutor;import java.util.concurrent.ThreadPoolExecutor;import java.util.concurrent.TimeUnit;/** * reads credit data from the database, applies the model, and records and transmits the results * / public class TestFullGCProblem01 {private static class CardInfo {BigDecimal price = new BigDecimal (0.0) String name = "Zhang San"; int age = 5; Date birthDate = new Date (); public void m () {}} private static ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor (50, new ThreadPoolExecutor.DiscardOldestPolicy ()); public static void main (String [] args) throws Exception {executor.setMaximumPoolSize (50); for (;;) {modelFit () Thread.sleep;}} private static void modelFit () {List taskList = getAllCardInfo (); taskList.forEach (info-> {/ / do something executor.scheduleWithFixedDelay (()-> {/ / do sth with info info.m ();}, 2,3, TimeUnit.SECONDS);}) } private static List getAllCardInfo () {List taskList = new ArrayList (); for (int I = 0; I

< 100; i++) { CardInfo ci = new CardInfo(); taskList.add(ci); } return taskList; }} java -Xms200M -Xmx200M -XX:+PrintGC com.test.jvm.gc.TestFullGCProblem01 一般是运维团队首先收到报警信息(CPU Memory) top命令观察到问题:内存不断增长 CPU占用率居高不下 top -Hp观察进程中的线程,哪个线程CPU和内存占比高 jps定位具体java进程 jstack定位线程状况,重点关注:WAITING BLOCKED eg. waiting on (a java.lang.Object) 假如有一个进程中100个线程,很多线程都在waiting on ,一定要找到是哪个线程持有这把锁 怎么找?搜索jstack dump的信息,找 ,看哪个线程持有这把锁RUNNABLE 作业:1:写一个死锁程序,用jstack观察 2 :写一个程序,一个线程持有锁不释放,其他线程等待 为什么阿里规范里规定,线程的名称(尤其是线程池)都要写有意义的名称。怎么样自定义线程池里的线程名称?(自定义ThreadFactory) jinfo pid jstat -gc动态观察gc情况 / 阅读GC日志发现频繁GC / arthas观察 / jconsole/jvisualVM/ Jprofiler(最好用) jstat -gc 4655 500 : 每个500个毫秒打印GC的情况 如果面试官问你是怎么定位OOM问题的?如果你回答用图形界面(错误) 1:已经上线的系统不用图形界面用什么?(cmdline arthas) 2:图形界面到底用在什么地方?测试!测试的时候进行监控!(压测观察) jmap -histo 4655 | head -20,查找有多少对象产生 jmap -dump:format=b,file=xxx pid : 线上系统,内存特别大,jmap执行期间会对进程产生很大影响,甚至卡顿(电商不适合) 1:设定了参数HeapDump,OOM的时候会自动产生堆转储文件 2:很多服务器备份(高可用),停掉这台服务器对其他服务器不影响 3:在线定位(一般小点儿公司用不到) java -Xms20M -Xmx20M -XX:+UseParallelGC -XX:+HeapDumpOnOutOfMemoryError com.test.jvm.gc.TestFullGCProblem01 使用MAT / jhat /jvisualvm 进行dump文件分析:https://www.cnblogs.com/baihuitestsoftware/articles/6406271.html jhat -J-mx512M xxx.dump http://192.168.17.11:7000 拉到最后:找到对应链接 可以使用OQL查找特定问题对象 找到代码的问题 jconsole远程连接 程序启动加入参数: java -Djava.rmi.server.hostname=192.168.17.11 -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=11111 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false XXX 如果遭遇 Local host name unknown:XXX的错误,修改/etc/hosts文件,把XXX加入进去 192.168.17.11 basic localhost localhost.localdomain localhost4 localhost4.localdomain4::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 关闭linux防火墙(实战中应该打开对应端口) service iptables stopchkconfig iptables off #永久关闭 windows上打开 jconsole远程连接 192.168.17.11:11111 jvisualvm远程连接 https://www.cnblogs.com/liugh/p/7620336.html (简单做法) jprofiler (收费)arthas在线排查工具 为什么需要在线排查? 在生产上我们经常会碰到一些不好排查的问题,例如线程安全问题,用最简单的threaddump或者heapdump不好查到问题原因。为了排查这些问题,有时我们会临时加一些日志,比如在一些关键的函数里打印出入参,然后重新打包发布,如果打了日志还是没找到问题,继续加日志,重新打包发布。对于上线流程复杂而且审核比较严的公司,从改代码到上线需要层层的流转,会大大影响问题排查的进度。 jvm观察jvm信息 thread定位线程问题 dashboard 观察系统情况 heapdump + jhat分析 jad反编译 动态代理生成类的问题定位 第三方的类(观察代码) 版本问题(确定自己最新提交的版本是不是被使用) redefine 热替换 目前有些限制条件:只能改方法实现(方法已经运行完成),不能改方法名, 不能改属性 m() ->

Mm ()

Sc-search class

Watch-watch method

Features not included: jmap

Card Table, the basic concept of GC algorithm

Because when doing YGC, you need to scan the entire OLD area (because the old area may be something pointing to the young area), which is very inefficient, so JVM designed CardTable. If an object in the OLD area CardTable points to the Y area, set it to Dirty. The next time you scan, you only need to scan Dirty Card. Structurally, Card Table is implemented in BitMap.

Concurrent marking algorithm

Difficulty: in the process of marking objects, the object reference relationship is changing

Tricolor labeling method

White: objects that are not marked

Gray: itself is marked, member variables are not marked

Black: both self and member variables have been marked complete

Graph TDA (A: black)-- > B (B: grey) A (A: black)-- > C (C: grey) A (A: black)-- > | add | D (D: White) B-> | Delete | D (D: White)

Missing mark (2 cases): missing mark refers to the original live object, but because it is not traversed, it is regarded as garbage collection.

During the remakr process, black points to white, and if the black is not rescanned, the label will be missed and the white object will be recycled as if there are no new references.

During the concurrent marking process, all references from gray to white are deleted, resulting in a missing label, at which point the white object should be recycled.

How to solve (2 ways):

Incremental update: incremental updates, focus on the increase in references, re-mark black as gray, and rescan attributes next time. (CMS uses this.)

SATB (snapshot at the beginning): focus on the deletion of the reference. When the point disappears, push the reference to the GC stack to make sure that the white color can still be scanned by GC. (G1 uses this approach)

Introduction to CMS

Concurrent Mark Sweep

A mostly concurrent, low-pause collector

4 phases

Initial mark

Concurrent mark

Remark

Concurrent sweep

Initial mark

STW will occur in this process, but because fewer objects will be found, the STW time will be very short.

Concurrent tagging

This process does not send STW

Relabel

In order to solve the problem that references to some objects no longer exist in the process of concurrent markup, it is necessary to re-tag

This process will occur, STW.

Concurrent cleanup

The process of concurrent cleanup may still generate garbage, which is called floating garbage and will be cleaned up the next time GC

The problem with CMS

Memory Fragmentation

-XX:+UseCMSCompactAtFullCollection-XX:CMSFullGCsBeforeCompaction defaults to 0, which means how many FGC it takes to compress.

Floating Garbage

Concurrent Mode Failure generation: if the concurrent collector is unable to finish reclaiming the unreachable objects before the tenured generation fills up, or if an allocation cannot be satisfiedwith the available free space blocks in the tenured generation, then theapplication is paused and the collection is completed with all the applicationthreads stopped

Solution: lower the threshold for triggering CMS

PromotionFailed

The solution is similar and there is enough room to keep the old age.

-XX:CMSInitiatingOccupancyFraction 92% can lower this value, so that CMS can keep enough space in the old age.

CMS log analysis

Execute the command: java-Xms20M-Xmx20M-XX:+PrintGCDetails-XX:+UseConcMarkSweepGC com.test.jvm.gc.TestFullGCProblem01

[GC (Allocation Failure) [ParNew: 6144K-> 640K (6144K), 0.0265885 secs] 6585K-> 2770K (19840K), 0.0268035 secs] [Times: user=0.02 sys=0.00, real=0.02 secs]

ParNew: younger generation collector

6144-> 640: comparison before and after collection

(6144): the capacity of the entire younger generation

6585-> 2770: the situation of the entire heap

(19840): entire heap size

[GC (CMS Initial Mark) [1 CMS-initial-mark: 8511K (13696K)] 9866K (19840K), 0.0040321 secs] [Times: user=0.01 sys=0.00, real=0.00 secs] / / 8511 (13696): older use (maximum) / / 9866 (19840): whole heap use (maximum) [CMS-concurrent-mark-start] [CMS-concurrent-mark: 0.018 secs] [Times: user=0.01 sys=0.00 Real=0.02 secs] / / the time here doesn't mean much. Because it is a concurrent execution of [CMS-concurrent-preclean-start] [CMS-concurrent-preclean: 0.000 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] / / Mark Card as Dirty Also known as Card Marking [GC (CMS Final Remark) [YG occupancy: 1597 K (6144 K)] [Rescan (parallel), 0.0008396 secs] [weak refs processing, 0.0000138 secs] [class unloading, 0.0005404 secs] [scrub symbol table, 0.0006169 secs] [scrub string table, 0.0004903 secs] [1 CMS-remark: 8511K (13696K)] 10108K (19840K), 0.0039567 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] / / STW stage YG occupancy: young generation occupation and capacity / / [Rescan (parallel): surviving object tags under STW / / weak refs processing: weak reference processing / / class unloading: uninstalling unused class// scrub symbol (string) table: / / cleaning up symbol and string tables which hold class-level metadata and / / internalized string respectively// CMS-remark: 8511K (13696K): old age occupation and capacity after stage / / 10108K (19840K): Heap occupancy and capacity after phase [CMS-concurrent-sweep-start] [CMS-concurrent-sweep: 0.005 to 0.005 secs] [Times: user=0.00 sys=0.00] Real=0.01 secs] / / tag has been completed Perform concurrent cleanup [CMS-concurrent-reset-start] [CMS-concurrent-reset: 0.000 user=0.00 sys=0.00 0.000 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] / / reset the internal structure to prepare for the next GC G1 introduction

Official introduction

G1 is a garbage collector used by server-side applications, which is aimed at multi-core, large-memory machines. It can achieve specified GC pause time in most cases while maintaining high throughput.

Compared with PS, G1 has about 10% to 15% lower throughput, but maintains response time at 200ms.

G1 uses the idea of divide and conquer to manage memory, dividing the memory into a Region. Each Region may be a generation, such as old, survivor, tenured, Humongous. Each area is not fixed.

Characteristics

Concurrent collection

Compressing free space does not extend the pause time of GC

More predictable GC pause time

Suitable for scenarios where high throughput is not required

Basic concept

CSet = CollectionSet a collection of partitions that can be recycled. Data that survives in CSet is moved to another available partition during the GC process, and partitions in CSet can come from Eden space, Survivor space, or older age. CSet takes up less than 1% of the entire heap space.

RSet = RememberedSet * * records the references of objects in other region to this region. The value is that the garbage collector doesn't need to scan the entire heap to find out who references objects in the current partition, just scan the RSet. RSet is maintained in each Region. * * because of the existence of RSet, you have to do something extra each time you assign a reference to an object, which means making some extra records in RSet (called write barrier in GC).

Detailed description of G1 log [GC pause (G1 Evacuation Pause) (young) (initial-mark), 0.0015790 secs] / / young-> Young Evacuation- > stage of mixed recovery of replicated living objects / / initial-mark Here is YGC mixed Old Age Recycling [Parallel Time: 1.5 ms] GC Workers: 1] / / A GC thread [GC Worker Start (ms): 92635.7] [Ext Root Scanning (ms): 92635.7] [Update RS (ms): 0] [Processed Buffers: 1] [Scan RS (ms): 0] [Code Root Scanning (ms): 0] [Object Copy (ms): 0.1] [Termination (ms): 0.0] [Termination Attempts: 1] [GC Worker Other (ms): 0.0] [GC Worker Total (ms): 1.2] [GC Worker End (ms): 92636.9] [Code Root Fixup: 0.0 ms] [Code Root Purge: 0.0 ms] [Clear CT: 0.0 ms] [Other: 0.1 ms] [Choose CSet: 0.0 ms] [Ref Proc: 0.0 ms] [Ref Enq: 0.0 ms] [Redirty Cards: 0.0 ms] [Humongous Register: 0.0 ms] [Humongous Reclaim: 0.0 ms] [Free CSet: 0.0 ms] [Eden: 0.0B (1024.0K)-> 0.0B (1024.0K) Survivors: 0.0B-> 0.0B Heap: 18.8m (20 .0m)-> 18.8m (20.0m)] [Times: user=0.00 sys=0.00 Real=0.00 secs] / / other stages of mixed recycling [GC concurrent-root-region-scan-start] [GC concurrent-root-region-scan-end, 0.0000078 secs] [GC concurrent-mark-start] / / cannot evacuation Conduct FGC [Full GC (Allocation Failure) 18M-> 18m (20m), 0.0719656 secs] [Eden: 0.0B (1024.0K)-> 0.0B (1024.0K) Survivors: 0.0B-> 0.0B Heap: 18.8m (20.0m)-> 18.8m (20.0m)], [Metaspace: 3876K-> 3876K (1056768K)] [Times: user=0.07 sys=0.00, real=0.07 secs] case summary

OOM is produced for a variety of reasons. Some programs do not necessarily generate OOM and continue to FGC (CPU soars high, but memory recovery is very low) (in the above case)

The problem of hardware upgrade system is stuttered (see above)

Improper use of thread pool leads to OOM problems (see above) constantly adding objects to List (too LOW)

Jira problem the actual system keeps rebooting to solve the problem add memory + replace the garbage collector G1 what is the real problem? I have no idea

Tomcat http-header-size oversize problem (Hector)

Lambda expression causes method zone overflow problem (MethodArea / Perm Metaspace) LambdaGC.java-XX:MaxMetaspaceSize=9M-XX:+PrintGCDetails

"C:\ Program Files\ Java\ jdk1.8.0_181\ bin\ java.exe"-XX:MaxMetaspaceSize=9M-XX:+PrintGCDetails "- javaagent:C:\ Program Files\ JetBrains\ IntelliJ IDEA Community Edition 2019.1\ lib\ idea_rt.jar=49316:C:\ Program Files\ JetBrains\ IntelliJ IDEA Community Edition 2019.1\ bin"-Dfile.encoding=UTF-8-classpath "C:\ Program Files\ Java\ jdk1.8.0_181\ jre\ lib\ charsets.jar C:\ Program Files\ Java\ jdk1.8.0_181\ jre\ lib\ deploy.jar;C:\ Program Files\ Java\ jdk1.8.0_181\ jre\ lib\ ext\ access-bridge-64.jar;C:\ Program Files\ Java\ jdk1.8.0_181\ jre\ lib\ ext\ cldrdata.jar;C:\ Program Files\ Java\ jdk1.8.0_181\ jre\ lib\ ext\ dnsns.jar;C:\ Program Files\ Java\ jdk1.8.0_181\ jre\ lib\ ext\ jaccess.jar C:\ Program Files\ Java\ jdk1.8.0_181\ jre\ lib\ ext\ jfxrt.jar;C:\ Program Files\ Java\ jdk1.8.0_181\ jre\ lib\ ext\ localedata.jar;C:\ Program Files\ Java\ jdk1.8.0_181\ jre\ lib\ ext\ nashorn.jar;C:\ Program Files\ Java\ jdk1.8.0_181\ jre\ lib\ ext\ sunec.jar;C:\ Program Files\ Java\ jdk1.8.0_181\ jre\ lib\ ext\ sunjce_provider.jar C:\ Program Files\ Java\ jdk1.8.0_181\ jre\ lib\ ext\ sunmscapi.jar;C:\ Program Files\ Java\ jdk1.8.0_181\ jre\ lib\ ext\ sunpkcs11.jar;C:\ Program Files\ Java\ jdk1.8.0_181\ jre\ lib\ ext\ zipfs.jar;C:\ Program Files\ Java\ jdk1.8.0_181\ jre\ lib\ javaws.jar;C:\ Program Files\ Java\ jdk1.8.0_181\ jre\ lib\ jce.jar C:\ Program Files\ Java\ jdk1.8.0_181\ jre\ lib\ jfr.jar;C:\ Program Files\ Java\ jdk1.8.0_181\ jre\ lib\ jfxswt.jar;C:\ Program Files\ Java\ jdk1.8.0_181\ jre\ lib\ jsse.jar;C:\ Program Files\ Java\ jdk1.8.0_181\ jre\ lib\ management-agent.jar;C:\ Program Files\ Java\ jdk1.8.0_181\ jre\ lib\ plugin.jar C:\ Program Files\ Java\ jdk1.8.0_181\ jre\ lib\ resources.jar;C:\ Program Files\ Java\ jdk1.8.0_181\ jre\ lib\ rt.jar;C:\ work\ ijprojects\ JVM\ out\ production\ JVM C:\ work\ ijprojects\ ObjectSize\ out\ artifacts\ ObjectSize_jar\ ObjectSize.jar "com.mashibing.jvm.gc.LambdaGC [GC (Metadata GC Threshold) [PSYoungGen: 11341K-> 1880K (38400K)] 11341K-> 1888K (125952K), 0.0022190 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] [Full GC (Metadata GC Threshold) [PSYoungGen: 1880K-> 0K (38400K)] [ParOldGen: 8K-> 1777K (35328K)] 1888K-> 1777K (73728K), [Metaspace: 8164K-> 8164K (1056768K)] 0.0100681 secs] [Times: user=0.02 sys=0.00, real=0.01 secs] [GC (Last ditch collection) [PSYoungGen: 0K-> 0K (38400K)] 1777K-> 1777K (73728K), 0.0005698 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] [Full GC (Last ditch collection) [PSYoungGen: 0K-> 0K (38400K)] [ParOldGen: 1777K-> 1629K (67584K)] 1777K-> 1629K (105984K), [Metaspace: 8164K-> 8156K (1056768K)] 0.0124299 secs] [Times: user=0.06 sys=0.00 Real=0.01 secs] java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0 (NativeMethod) at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke (Method.java:498) at sun.instrument.InstrumentationImpl.loadClassAndStartAgent (InstrumentationImpl.java:388) at sun.instrument.InstrumentationImpl.loadClassAndCallAgentmain (InstrumentationImpl. Java:411) Caused by: java.lang.OutOfMemoryError: Compressed class space at sun.misc.Unsafe.defineClass (Native Method) at sun.reflect.ClassDefiner.defineClass (ClassDefiner.java:63) at sun.reflect.MethodAccessorGenerator$1.run (MethodAccessorGenerator.java:399) at sun.reflect.MethodAccessorGenerator$1.run (MethodAccessorGenerator.java:394) at java.security.AccessController.doPrivileged (Native Method) at sun.reflect.MethodAccessorGenerator.generate (MethodAccessorGenerator.java : 393) at sun.reflect.MethodAccessorGenerator.generateSerializationConstructor (MethodAccessorGenerator.java:112) at sun.reflect.ReflectionFactory.generateConstructor (ReflectionFactory.java:398) at sun.reflect.ReflectionFactory.newConstructorForSerialization (ReflectionFactory.java:360) at java.io.ObjectStreamClass.getSerializableConstructor (ObjectStreamClass.java:1574) at java.io.ObjectStreamClass.access$1500 (ObjectStreamClass.java:79) at java.io.ObjectStreamClass$3.run (ObjectStreamClass.java:519) At java.io.ObjectStreamClass$3.run (ObjectStreamClass.java:494) at java.security.AccessController.doPrivileged (Native Method) at java.io.ObjectStreamClass. (ObjectStreamClass.java:494) at java.io.ObjectStreamClass.lookup (ObjectStreamClass.java:391) at java.io.ObjectOutputStream.writeObject0 (ObjectOutputStream.java:1134) at java.io.ObjectOutputStream.defaultWriteFields (ObjectOutputStream.java:1548) at java.io.ObjectOutputStream.writeSerialData ( ObjectOutputStream.java:1509) at java.io.ObjectOutputStream.writeOrdinaryObject (ObjectOutputStream.java:1432) at java.io.ObjectOutputStream.writeObject0 (ObjectOutputStream.java:1178) at java.io.ObjectOutputStream.writeObject (ObjectOutputStream.java:348) at javax.management.remote.rmi.RMIConnectorServer.encodeJRMPStub (RMIConnectorServer.java:727) at javax.management.remote.rmi.RMIConnectorServer.encodeStub (RMIConnectorServer.java:719) at javax.management.remote. Rmi.RMIConnectorServer.encodeStubInAddress (RMIConnectorServer.java:690) at javax.management.remote.rmi.RMIConnectorServer.start (RMIConnectorServer.java:439) at sun.management.jmxremote.ConnectorBootstrap.startLocalConnectorServer (ConnectorBootstrap.java:550) at sun.management.Agent.startLocalManagementAgent (Agent.java:137)

Direct memory overflow problem (rare) "in-depth understanding of Java virtual machine" P59, using Unsafe to allocate direct memory, or using NIO

Stack overflow problem-Xss setting is too small

Compare the similarities and differences between the two programs and analyze which is the better way to write it:

Object o = null;for (int item0; I

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