How to set memory limit for OOM Killer for chrome?

我是研究僧i 提交于 2020-03-01 05:54:52

问题


chrome invoked oom-killer: gfp_mask=0xd0, order=0, oom_score_adj=300

I'm getting the above error while testing with headless chrome browser + Selenium.


回答1:


This error message...

chrome invoked oom-killer: gfp_mask=0xd0, order=0, oom_score_adj=300

...implies that the ChromeDriver controlled Browsing Context i.e. Chrome Browser invoked the OOM Killer due to out-of-memory error.


Out of Memory

Out of Memory error messages can appear when you attempt to start new programs or you try to use programs that are already running, even though you still have plenty of physical and pagefile memory available.


OOM Killer

The OOM Killer or Out Of Memory Killer is a process that the linux kernel employs when the system is critically low on memory. This situation occurs because the linux kernel has over allocated memory to its processes. When a process starts it requests a block of memory from the kernel. This initial request is usually a large request that the process will not immediately or indeed ever use all of. The kernel, aware of this tendency for processes to request redundant memory, over allocates the system memory. This means that when the system has, for example, 2GB of RAM the kernel may allocate 2.5GB to processes. This maximises the use of system memory by ensuring that the memory that is allocated to processes is being actively used. Now, if enough processes begin to use all of their requested memory blocks then there will not be enough physical memory to support them all. This means that the running processes require more memory than is physically available. This situation is exactly when linux kernel invoke the OOM Killer to review all running processes and kill one or more of them in order to free up system memory and keep the system running.


Chrome the first victim of the OOM Killer

Surprisingly it seems Chrome Browser Client is the first victiom of the oom killer. As the Linux OOM Killer kills the process with the highest score=(RSS + oom_score_adj), the chrome tabs are killed because they have an oom_score_adj of 300 (kLowestRendererOomScore = 300 in chrome_constants.cc) as follows:

#if defined(OS_LINUX)
const int kLowestRendererOomScore = 300;
const int kHighestRendererOomScore = 1000;
#endif  

Details

This issue is a known issue and can be easily reproduced. We have discussed this issue in length and breadth with in oom_score_adj too high - chrome is always the first victiom of the oom killer. The goal was to adjust the OOM in Chrome OS to make sure the most-recently-opened tab isn't killed as it appeared OOM killer prefers recent processes by default. But on Linux distros that won't reflect and you would get undesirable behavior where Chrome procs get killed over other procs that probably should have been killed instead.


Solution

Some details interms of the error stack trace would have helped us to suggest you some changes in terms of:

  • total-vm usage
  • Physical memory
  • Swap memory

You can find a couple of relevant discussions in:

  • Understanding the Linux oom-killer's logs
  • what does anon-rss and total-vm mean
  • determine vm size of process killed by oom-killer

However, there was a code review to address this issue but the discussion still seems still in status Assigned with Priority:2 with in:

  • Linux: Adjust /proc/pid/oom_adj to sacrifice plugin and renderer processes to the OOM killer

tl; dr

java.lang.OutOfMemoryError: unable to create new native thread error using ChromeDriver and Chrome through Selenium in Spring boot


Outro

Chromium OS - Design Documents - Out of memory handling



来源:https://stackoverflow.com/questions/59715649/how-to-set-memory-limit-for-oom-killer-for-chrome

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!