当前位置:网站首页>JVM memory overflow
JVM memory overflow
2022-06-22 08:26:00 【ambition_ forever】
1、 Heap overflow
Most memory overflows are heap overflows , The reason is that a large number of objects occupy heap space , And these objects hold strong references , It can't be recycled .-Xmx Parameter specifies when the heap space size is smaller than the object size , Overflow happens naturally .
Error message :java.lang.OutOfMemoryError: Java heap space
To reduce heap overflow errors , On the one hand, you can use -Xmx Specify a larger heap space . In addition, you can use MAT perhaps VisualVM Tools such as , Find objects that take up a lot of heap space , And optimize the code reasonably .
2、 Direct memory overflow
stay Java Of NIO in , Support direct memory usage , That is, through Java The code gets a block of off heap memory , This memory is directly requested from the operating system . Direct memory requests are generally slower than heap memory , But access speed is faster than heap memory , So for those spaces that can be reused and accessed frequently , Using direct memory can improve the performance of the system , But there is no memory JVM trusteeship , Improper use can easily trigger a direct memory overflow , Cause downtime .
-XX:+PrintGCDetails Output GC details
Error message :java.lang.OutOfMemoryError: Direct buffer memory
Direct memory does not necessarily trigger GC, Trigger direct memory usage to -XX:MaxDirectMemorySize Set the value of . Therefore, it is necessary to ensure that the memory does not overflow FullGC. Or set up a system reachable -XX:MaxDirectMemorySize value . Via displayed gc It can reclaim direct memory .
Without using -XX:MaxDirectMemorySize When setting the maximum and most direct memory space , By default, the maximum available direct memory is equal to -Xmx That is, the size of the heap space .
Avoid direct memory overflow :
1、 reasonable GC
2、 Set the system allowable -XX:MaxDirectMemorySize
3、 Set small -Xmx
3、 Too many threads cause OOM
The stack space of a thread is also allocated outside the heap , Very similar to direct memory , If you want the system to support more threads , Then you should use a smaller heap space .
Error message : unable to create new native thread
as a result of Java The process has reached the maximum available memory . Reduce heap space , Reduce the space occupied by threads -Xss Parameter can specify the stack space of the thread .
-Xmx1g -Xss128k Heap space is still 1g, But the thread stack space is reduced to 128k, The remaining available memory can accommodate more threads .
4、MetaspaceOOM
Metaspace Meta space mainly stores metadata information of classes , for example : type 、 attribute 、 Method 、 Access restrictions, etc . so Metaspace Space growth is due to reflection class loading 、 Class loading generated by dynamic proxy , in other words Metaspace The size of is related to the loaded data , The more classes you load metaspace The more memory it takes up .
-XX:+TraceClassLoading -XX:+TraceClassUnloading You can record the loading and unloading of classes .
5、GC Inefficiency leads to OOM
GC Is the key to memory reclamation , If GC Efficiency underground , Then the performance of the system will be seriously affected . If the heap space is too large ,GC It will take more time , And the objects released by recycling are less , Virtual machines think GC It is possible to throw OOM, When something happens , Throw out GC overhead limit exceeded.
1、 Spend on GC More time than 98%
2、 Whether the memory released by the older generation is less than 2%
3、eden Whether the area free memory is less than 2%
4、 Is it continuous 5 Time At the same time Above case.
边栏推荐
- Detailed sorting of Oracle and MySQL pages
- 第八章 Web项目测试(此章完结)
- Coding complexity C (n)
- Optimization of MySQL paging scheme by database and table
- The role of subject integration in steam Education
- 解读创客教育中的技术一族
- 并发三大特性1-可见性
- Mysql5.6.36 tutorial
- [Oracle database] mammy tutorial Day11 numerical function
- Mysql+orcle (SQL implements recursive query of all data of child nodes)
猜你喜欢

Synchronized

EURUSD,H1: invalid lots amount for OrderSend function

年度十强!赛宁网安再次入围《中国数字安全百强报告》

Interpreting the technology group in maker Education

并发三大特性1-可见性

The role of subject integration in steam Education

Weekly recommended short video: what is the "computing world"?

Implementation and landing of any to any real-time voice change RTC dev Meetup

深入理解MySQL索引凭什么能让查询效率提高这么多?

Easyui数据表实现增删改
随机推荐
Carry out effective maker education courses and activities
安装 MySQL 服务时提示 InstallRemove of the Service Denied
Mt4/mql4 getting started to proficient in foreign exchange EA automatic trading tutorial - common functions of MQL language
Learn data warehouse together - Zero
Preview function implementation of Android kotlin Camera2
Installing SQL Server 2008 by image in Windows Service 2008
SQL triggers
QT custom composite control (class promotion function)
377. combined total Ⅳ
学科融合对steam教育的作用
Submit values of various inputs of the form
一文搞懂one-hot和embedding
Multi tenancy and Implementation
开展有效的创客教育课程与活动
I spring and autumn web Penetration Test Engineer (elementary) learning notes (Chapter 3)
矩阵运算
Synchronized
Mt4-mql4 language EA automatic transaction programming introduction to proficiency
Chmod Chmod command
计算天数()