Linux OOM(out of memory)

Mango milk 2021-02-23 17:01:51
linux oom memory


The decision system appears oom When , What to do . The three accepted values are as follows :

0 - The default value is , When there is a oom When , Trigger oom killer

1 - The program has cpuset、memory policy、memcg Under the constraint of OOM, Consider not panic, But start OOM killer. Other conditions trigger kernel panic, That is, the system will restart directly

2 - When there is a oom, Direct trigger kernel panic, That is, the system will restart directly

Linux User memory is allocated during read and write , So the system found that the need for memory basically occurs in handle_mm_fault() When ( Other special processes are similar , Here to ignore ),handle_mm_fault() To allocate memory for missing pages , It's easy to tune alloc_pages() Series of functions , So as to adjust prepare_alloc_pages(), And then enter the __alloc_pages_direct_reclaim(), The buffer that can be cleared to the disk has been cleared once . After that, the memory can't be allocated , I have to enter OMM Killer 了 (pagefault_out_of_memory()).

In this state , The memory in the system can only be occupied by the running process and kernel , Everybody won't let me , The system is dead
In order to prevent the system from crashing when the physical memory of the system is not enough , And choose the program that takes the most memory , Take it Kill fall !

swap: stay linux Inside , When physical memory is out of use , And a new program requests to allocate memory , that linux You will choose to exchange data not used by other programs to physical disk (swap out), Wait until the program is ready to use (swap in). The disadvantages of doing so are obvious ,swap in/swap out The price here is higher , Compared to keeping data in memory all the time , More disk reading operations

OOM:out of memory, Referring to linux Inside , Due to system memory pressure , The system will choose to protect some system processes , And some other processes kill fall , Free memory .

How to avoid the process because OOM The mechanism is kill fall ?

  1. And OOM The related documents are /proc//oom_adj 、 /proc//oom_score. The former is a weight -16 to 15, The default is 0, Set to -17 It means never to be kill, In other cases, the higher the value, the easier it is to be kill. The latter is a value it calculates , It is based on this value to select which processes are kill Dropped .
  2. Put it on the top for use swap The third method in overcommit Parameters , Because it can't allocate memory, it will return an error , So it's never possible to run out of memory .OOM It won't have an impact .

Reference documents :`

本文为[Mango milk ]所创,转载请带上原文链接,感谢

  1. k8s-prometheus
  2. Linux Disk Command
  3. Linux FS
  4. 使用docker-compose &WordPress建站
  5. Linux Command
  6. This time, thoroughly grasp the depth of JavaScript copy
  7. Linux Disk Command
  8. Linux FS
  9. Using docker compose & WordPress to build a website
  10. Linux Command
  11. 摊牌了,我 HTTP 功底贼好!
  12. shiro 报 Submitted credentials for token
  13. It's a showdown. I'm good at it!
  14. Shiro submitted credentials for token
  15. Linux Stress test
  16. Linux Root Disk Extension
  17. Linux Stress test
  18. Linux Root Disk Extension
  19. Redis高级客户端Lettuce详解
  20. springboot学习-综合运用(一)
  21. 忘记云服务器上MySQL数据库的root密码时如何重置密码?
  22. Detailed explanation of lettuce, an advanced client of redis
  23. Springboot learning integrated application (1)
  24. Linux File Recover
  25. Linux-Security
  26. How to reset the password when you forget the root password of MySQL database on the cloud server?
  27. Linux File Recover
  28. Linux-Security
  29. LiteOS:盘点那些重要的数据结构
  30. Linux Memory
  31. Liteos: inventory those important data structures
  32. Linux Memory
  33. 手把手教你使用IDEA2020创建SpringBoot项目
  34. Hand in hand to teach you how to create a springboot project with idea2020
  35. spring boot 整合swagger2生成API文档
  36. Spring boot integrates swagger2 to generate API documents
  37. linux操作系统重启后 解决nginx的pid消失问题
  38. Solve the problem of nginx PID disappearing after Linux operating system restart
  39. JAVA版本号含义
  40. The meaning of java version number
  41. 开源办公开发平台丨Mysql5.7两套四节点主从结构环境搭建教程(二)
  42. 开源办公开发平台丨Mysql5.7两套四节点主从结构环境搭建教程(一)
  43. Open source office development platform mysql5.7 two sets of four node master-slave structure environment building tutorial (2)
  44. HTTP的“无状态”和REST的“状态转换”
  45. Open source office development platform mysql5.7 two sets of four node master-slave structure environment building tutorial (1)
  46. 【大数据哔哔集20210128】使用Hive计算环比和同比
  47. 【大数据哔哔集20210125】Kafka将逐步弃用对zookeeper的依赖
  48. 【大数据哔哔集20210124】有人问我Kafka Leader选举?我真没慌
  49. 【大数据哔哔集20210123】别问,问就是Kafka高可靠
  50. Spring 事务、异步和循环依赖有什么关系?
  51. Spring 动态代理时是如何解决循环依赖的?为什么要使用三级缓存?
  52. "Stateless" of HTTP and "state transition" of rest
  53. [big data bibiji 20210128] use hive to calculate month on month and year on year
  54. [big data bibiji 20210125] Kafka will gradually abandon its dependence on zookeeper
  55. [big data beeps 20210124] someone asked me about Kafka leader election? I'm not in a panic
  56. [big data bibiji 20210123] don't ask, ask is Kafka highly reliable
  57. jQuery Gantt Package 在Visual Studio中创建一个新的ASP.NET项目
  58. What is the relationship between spring transactions, asynchrony, and circular dependencies?
  59. How to solve circular dependency in spring dynamic proxy? Why use level 3 caching?
  60. Unicode码的二进制转换(Java)