java recursively achieve multi -level menu

2023-01-23   ES  

Starting from Java8, the memory model in Java introduced a new memory area called Metaspace and deleted Permgen. Generally, the names and fields of the class, the method of the method with method bytecode, the constant pool, and the access limit will exist in the meta space.
METASPACE space growth is mostly caused by reflex loading and dynamic proxy class loading, that is, the size of Metaspace is related to the data of loading class. Causes Metaspace memory overflow to analyze from the above data sources.

  1. Ievant introduces too much monitoring and analytical categories. For example, when the project is launched, the MaxmetaspaceSize is set to 128m. Later, due to the addition of various monitoring and analysis functions, the project startup is close to 128m, which will naturally lead to insufficient space.

    The number of access to a certain business scenario has increased, causing Metaspace memory overflow.

  2. jvm parameter configuration error. This is a bit deep. First of all, it is necessary to determine whether the reflected object is modified by the softreference soft reference. If yes, you need to check the parameter configuration of the XX: Softreflrupolicymspermb. SoftRuPolicyMSPERMB parameter probably means that the survival time of the SoftReference object that can be maintained every 1m free space (the unit is MS millisecond). The JVM default is 1000ms. If it is set to 0, it will cause the soft reference object to be recycled immediately, which will cause frequent frequent. The reflection generates a new class, which does not achieve the effect of reuse, which leads to the surge in Metaspace.
  3. class loader leak. This is more headache. First of all, the DUMP files that are storage must be analyzed. The heap should be charged to generate DUMP files after at least one classloader instance leakage, so as to analyze the reference of the leakage instance to prevent it from being collected by garbage. You can add -xx:+HeapdumponoutOutofMemoryerror JVM parameters, and then run and re-deploy the application until it collapses java.lang.outoFMemoryerror errors. Before collapse, the Dump file is automatically generated. The file name is similar to java_pid18148.hprof. The .hprof file is located in the starting directory of the application server. You can also specify the directory through -xx: heapdumppath =/Directory parameter. Analysis .hprof files are best to use tools. Each tool is different. Finally, by finding references and finding unnecessary references, the cause of leakage can be found to prevent the class loader from being collected by garbage. This quotation may be in business code, third -party library, application server or JVM.

The solution under normal circumstances is also very simple:

  1. If the application consumes the meta -space area in the memory, re -increase the configuration of the meta space after evaluation. If you change 128m to 256m.
  2. can also delete the configuration parameters of MaxmetaspaceSize to completely cancel the restrictions on the size of the meta -space, but this does not solve the fundamental problem, but it has temporarily canceled the emergence of OOM and left a certain time to check and position the problem.
  3. If it is caused by -xx: SoftRefluPolicy Mspermbb, set it to 1000 (1s).

  1. Arthas diagnostic tool (java online diagnostic weapon arthas)
  2. Original jmap and jhat
  3. MAT (Memory Analyst Tool)

JVM The setting of each parameter value of each, set proportional settings according to the memory size of the application. For individual specific values, it can be fine -tuned or default.

-XMS initial heap size
-XMX maximum pile size
-xmn young generation size
-XSS The stack size of each thread
-XX: Newratio = N ratio of young and older generations.
-XX: Survivorratio = N to N to the ratio of the Eden area and two Survivor regions in the young generation.
-xx: maxpermsize = n for the size of a long -term generation
-XX: maxtenRingthreshold = 0 maximum age of garbage

java -Xmx3550m -Xms3550m -Xss128k -XX:NewRatio=4 -XX:SurvivorRatio=4 -XX:MaxPermSize=16m -XX:MaxTenuringThreshold=0

-XX:+UseSerialGC serial collector
-XX:+UseParallelgc parallel collector
-XX: Parallelgcthreads The number of CPUs used in parallel collectors. Number of threads in parallel
-XX:+USEPARALLOLOLDGC Parallel Parallel Elderly Collectioner
-XX: Maxgcpausemillis for the longest time for the recycling of young trash each time
-XX:+UseadaptiveSizePolicy parallel collector tuning
-XX:+UseConcmarksweepgc is collected in the old age, and settings when -XX: Newratio
-XX:+UseParnewgc’s young generation is collected in parallel. JVM is set without configuration.

-XX:+UseParallelGC -XX:ParallelGCThreads=20 -XX:+UseParallelOldGC -XX:MaxGCPauseMillis=100-XX:+UseAdaptiveSizePolicys -XX:+UseConcMarkSweepGC

command line parameters, some print information, use during debugging


Related Posts

WIN2003 IIS minimum authority distribution batch file

Intermediate (CDN) VPN in the network

[linxu] Subreaper set up the grandfather process to take over the grandson process

Android 4.4.2 Exfat transplants

java recursively achieve multi -level menu

Random Posts

Summary of Electric Tournament (4) -AD9834 of the chip summary of waveforms

qt5 Daily Study (Wed) QT login dialog box Bryce1010

kafka Implement MYSQL incremental synchronization

PTA Zhejiang University Edition “C Language Program Design (3rd Edition)” Title Collection 2-5 Seeking N itself n and

Use batch process startup and close SAP MMC