当前位置:网站首页>Introduction to OOM
Introduction to OOM
2022-07-18 23:43:00 【jerry_ dyy】
OOM,Out Of Memory, out of memory , Memory overflow will lead to JVM Hanged up .
Before we start JVM When , Some memory parameters are specified ,JVM Memory size is limited , If you keep putting things inside , Then it will happen under certain circumstances OOM.
Let's take a look at which areas will happen OOM, And under what conditions will it happen OOM.
JVM The memory area can be divided into : Method area ( Metadata area ), Heap memory , Virtual machine stack , Native Method Stack , Program counter .
Program counter :
Where the program counter , Is private to each thread , And even if you save a bytecode execution address , There is no memory overflow .
Virtual machine stack :
The virtual machine stack is also thread private , What is stored inside is a stack frame , Corresponding to the execution of one method after another , It disappears automatically after it comes out of the stack , There is no memory overflow , But when infinite is put on the stack , Will cause stack overflow :Stack Over Flow. Generally, the stack size of each thread is 500KB, or 1MB, The size of a stack frame is 1KB, Unless a thread calls 500 A way , or 1000 A way , But the call chain of normal code can never be so deep , More commonly lead to Stack Over Flow The reason is that the method calls itself :
public void test(){
System.out.println(“test here”);
test();
}
like this , It will lead to execution to test() Method's thread is infinite on the stack , Eventually lead to Stack Over Flow.
Metadata area :
In the metadata area JVM All classes loaded through the class loader during operation . When the metadata area is full, it will trigger Full GC,Full GC The classes in the metadata area will be recycled , But to recycle a class , The conditions are very harsh : The class loader of this class must be recycled first , All instance objects of this class must be recycled first . If Full GC After that, the metadata area is still full , At this time, continue to put new things inside , It triggers OOM.
Metadata area occurs OOM There are two reasons :
The first reason : Many engineers don't understand JVM Operating principle , The metadata area size is not set , The default metadata area size is directly used when the system is launched , But for some large systems , There are many classes to load , And rely on more jar package ,jar The classes in the package should also be loaded , Eventually lead to , The metadata area cannot hold the classes that need to be loaded , Lead to OOM.
The second reason : When many people write code , Will pass cglib Technology such as dynamic generation of a proxy class , Once the code is not under control , Then too many classes may be generated , Originally, you only need to generate a class object , As a result, each request needs to generate a class , Eventually, there are too many metadata areas cglib Dynamically generated classes , Cause metadata area OOM.
Heap memory :
Heap memory stores all the created objects , Heap memory is divided into new generation and old generation , The new generation is in Young GC after , Even if Survivor There's no room for , There are also older generations to provide space guarantees , So the new generation will not happen OOM. But the elderly generation is carrying on Full GC after , If there is still not enough space to store Young GC After the object , Heap memory OOM.
In the old days OOM Why :
The first reason : The concurrency carried by the system is too large , As a result, a large number of requests are still in the state of being processed , References to a large number of objects have not been lost , A lot of objects survive ,Young GC Then put it into the old generation ,Full GC After that, there is still not much recycling , continue Young GC Then put it into the old generation , Old age OOM.
The second reason : The system has a memory leak . stay java Memory leaks in refer to : Some objects are no longer used , But such objects still have references . Lead to GC These objects cannot be recycled , Which leads to OOM.
边栏推荐
- Data-addressing Mode
- 可持续水力科学与绿色基础设施国际会议18-19日
- 动态内存管理(C语言)下--常见错误及大厂笔试题
- Pytest interface automation testing framework | Interface Testing Overview
- Google icons library compose can be used directly.
- 绝地求生 吃鸡 98k 不自动关镜子
- APP商品详情源数据接口
- Common password regular expressions
- Google icons 库 Compose就可以直接用。
- pytest接口自动化测试框架 | conftest.py和@pytest.fixture()结合
猜你喜欢

Google icons 库 Compose就可以直接用。

Canadian deployer Canadian adapter image construction, deployment

Compose 轮播图

响应式表单样式透明设计
![Hibench generates benchmark data sets [wordcount as an example]](/img/c9/730cacfdfa677dcc8045edb4b1e02c.png)
Hibench generates benchmark data sets [wordcount as an example]

yarn /nmp全局安装后,命令不生效

5.< tag-动态规划和完全背包问题>lt.70. 爬楼梯 || 进阶版 + lt.322. 零钱兑换 + lt.139. 单词拆分 + lt.279.完全平方数 dbc

nodeJS编译环境下使用yarn工具的安装与使用方法

在安装虚拟机时,”intel vt-x 处于禁用状态“ 如何解决

Record of SQL questions of Niuke this week
随机推荐
Web crawler technology from entry to mastery (penetration of high-end operations) Chapter 2
验证两个字符串一致
STM32F1与STM32CubeIDE编程实例-W25Q-SPI-Flash与LittleFS移植
二叉树心得
nodeJS编译环境下使用yarn工具的安装与使用方法
Mysql索引的使用
开户需要注意的是什么?请问手机开户股票开户安全吗?
Wanzi detailed C language document
嘘!摸鱼神器,别让老板知道!| 语音实时转文本,时序快速出预测,YOLOv6在就能用,一行命令整理CSV | ShowMeAI资讯日报
canvas无数个三角形动画js特效
Programming examples of stm32f1 and stm32cubeide-w25q-spi-flash and littlefs porting
Pytest interface automation test framework | Interface Association
每日一题:最近请求次数(剑指offer042)
微信小程序_16,组件的生命周期
[white box test] design method of logic coverage and path test
搭建夜莺集群监测系统
Use of MySQL index
nodejs不支持ES6模块化规范的解决方案
Solve the problem that WinDbg cannot load ntdll symbols
pytest接口自动化测试框架 | @pytest.fixture()装饰器