`
bzhang
  • 浏览: 254976 次
  • 性别: Icon_minigender_1
  • 来自: 大连
社区版块
存档分类
最新评论

OOM killer "Out of Memory: Killed process SOLUTION

阅读更多

Since this problem seems to popup on different lists, this message has
been cross-posted to the general Red Hat discussion list, the RHEL3
(Taroon) list and the RHEL4 (Nahant) list. My apologies for not having
the time to post this summary sooner.

I would still be banging my head against this problem were it not for
the generous assistance of Tom Sightler <ttsig@xxxxxxxxxxxxx> and Brian
Long <brilong@xxxxxxxxx>.

In general, the out of memory killer (oom-killer) begins killing
processes, even on servers with large amounts (6Gb+) of RAM. In many
cases people report plenty of "free" RAM and are perplexed as to why the
oom-killer is whacking processes. Indications that this has happened
appear in /var/log/messages:
Out of Memory: Killed process [PID] [process name].

In my case I was upgrading various VMware servers from RHEL3 / VMware
GSX to RHEL4 / VMware Server. One of the virtual machines on a server
with 16Gb of RAM kept getting whacked by the oom-killer. Needless to
say, this was quite frustrating.

As it turns out, the problem was low memory exhaustion. Quoting Tom:
"The kernel uses low memory to track allocations of all memory thus a
system with 16GB of memory will use significantly more low memory than a
system with 4GB, perhaps as much as 4 times. This extra pressure
happens from the moment you turn the system on before you do anything at
all because the kernel structures have to be sized for the potential of
tracking allocations in four times as much memory."

You can check the status of low & high memory a couple of ways:

# egrep 'High|Low' /proc/meminfo
HighTotal: 5111780 kB
HighFree: 1172 kB
LowTotal: 795688 kB
LowFree: 16788 kB

# free -lm
total used free shared buffers cached
Mem: 5769 5751 17 0 8 5267
Low: 777 760 16 0 0 0
High: 4991 4990 1 0 0 0
-/+ buffers/cache: 475 5293
Swap: 4773 0 4773

When low memory is exhausted, it doesn't matter how much high memory is
available, the oom-killer will begin whacking processes to keep the
server alive.

There are a couple of solutions to this problem:

If possible, upgrade to 64-bit Linux. This is the best solution because
*all* memory becomes low memory. If you run out of low memory in this
case, then you're *really* out of memory. ;-)

If limited to 32-bit Linux, the best solution is to run the hugemem
kernel. This kernel splits low/high memory differently, and in most
cases should provide enough low memory to map high memory. In most
cases this is an easy fix - simply install the hugemem kernel RPM &
reboot.

If running the 32-bit hugemem kernel isn't an option either, you can try
setting /proc/sys/vm/lower_zone_protection to a value of 250 or more.
This will cause the kernel to try to be more aggressive in defending the
low zone from allocating memory that could potentially be allocated in
the high memory zone. As far as I know, this option isn't available
until the 2.6.x kernel. Some experimentation to find the best setting
for your environment will probably be necessary. You can check & set
this value on the fly via:
# cat /proc/sys/vm/lower_zone_protection
# echo "250" > /proc/sys/vm/lower_zone_protection

To set this option on boot, add the following to /etc/sysctl.conf:
vm.lower_zone_protection = 250

As a last-ditch effort, you can disable the oom-killer. This option can
cause the server to hang, so use it with extreme caution (and at your
own risk)!
Check status of oom-killer:
# cat /proc/sys/vm/oom-kill

Turn oom-killer off/on:
# echo "0" > /proc/sys/vm/oom-kill
# echo "1" > /proc/sys/vm/oom-kill

To make this change take effect at boot time, add the following
to /etc/sysctl.conf:
vm.oom-kill = 0

For processes that would have been killed, but weren't because the oom-
killer is disabled, you'll see the following message
in /var/log/messages:
"Would have oom-killed but /proc/sys/vm/oom-kill is disabled"

Sorry for being so long-winded. I hope this helps others who have
struggled with this problem.

分享到:
评论

相关推荐

    有关OOM KILLER的一些理解

    OOM Killer,全称为Out of Memory Killer,是Linux内核中的一种机制,用于处理系统内存不足的情况。当系统内存耗尽时,为了避免整个系统的崩溃,OOM Killer会选择并终止一些进程来释放内存,从而确保系统的稳定运行...

    ANDROIDBITMAP内存限制OOM,OUTOFMEMORY.pdf

    文档标题和描述中提到的“ANDROIDBITMAP内存限制OOM,OUTOFMEMORY”指的就是在处理位图(BITMAP)时超出了虚拟机(VM)的内存预算,导致系统抛出OutOfMemoryError异常。 根据给出的内容部分,我们可以推断出以下知识...

    Linux系统的OOM Killer处理机制.docx

    在 Linux 系统中,OOM Killer处理机制是通过out_of_memory()函数来触发的,该函数会调用select_bad_process()函数来选择一个“bad”进程杀掉。select_bad_process()函数会根据进程的内存占用情况来判断和选择一个...

    ANDROIDBITMAP内存限制OOM,OUTOFMEMORY[文].pdf

    在Android开发中,我们经常会遇到内存管理的问题,特别是与Bitmap相关的内存溢出(Out Of Memory,简称OOM)问题。Bitmap对象是Android系统中用于处理图像数据的重要类,但由于其消耗大量的内存,不当使用可能导致...

    Android 加载大图及多图避免程序出现OOM(OutOfMemory)异常

    Android 加载大图及多图避免程序出现OOM(OutOfMemory)异常 1、高效加载大图片 我们在编写Android程序的时候经常要用到许多图片,不同图片总是会有不同的形状、不同的大小,但在大多数情况下,这些图片都会大于我们...

    android camera out of memory安卓照相机OOM问题的解决

    如果不能使用,请修改根目录下的project.property的android:target为你当前有的target(不知道怎么改的同学可以从8到21一个个数字去试哦) ...但打开时无自动聚焦,这个问题有需要的同学可以自己加上去哦。...

    【性能】OOM原理解析:LowMemoryKiller原理

    1 概述 Android的设计理念之一,便是应用程序退出,但进程还会继续存在系统以便...Android基于Linux的系统,其实Linux有类似的内存管理策略——OOM killer,全称(Out Of Memory Killer), OOM的策略更多的是用于分配内存

    Android-OOM.rar_memory android_memory for Android_out

    在Android开发过程中,"Out Of Memory"(OOM)错误是一个常见的问题,特别是在处理大量数据、图像或者长时间运行的任务时。这个错误表示应用程序消耗了过多的内存,超过了系统分配的限制,导致系统无法再为该应用...

    MySQL OOM 系统二 OOM Killer

    在Linux系统中,当内存资源紧张,即将耗尽时,为避免系统崩溃,Linux内核引入了一种称为OOM (Out Of Memory) Killer的机制。OOM Killer会选择性地杀死某些进程以回收内存。这一机制主要针对系统可用内存(包括Swap...

    OOM分析工具-MemoryAnalyzer.zip

    当应用程序出现Out of Memory (OOM)错误时,通常意味着系统无法分配足够的内存来执行任务,这时就需要借助专业的分析工具来查找问题的根源。MemoryAnalyzer(MAT)是IBM开发的一款强大的JVM堆内存分析工具,它能够...

    Pytorch GPU显存充足却显示out of memory的解决方式

    在使用PyTorch进行深度学习模型训练时,有时会遇到一个常见的问题,即GPU显存充足,但在运行过程中却报出“out of memory”错误。这种情况可能会让人困惑,因为直观上,既然显存足够,就不应该出现这样的问题。本文...

    elasticdump报错

    FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory 1: node::Abort() [node] 2: 0x8cd49c [node] 3: v8::Utils::ReportOOMFailure(char const*, bool) [node] 4: v8::...

    MySQL Slave 触发 oom-killer解决方法

    Mar 9 11:29:16 xxxxxx kernel: mysqld invoked oom-killer: gfp_mask=0x201da, order=0, oom_adj=0, oom_score_adj=0 Mar 9 11:29:16 xxxxxx kernel: mysqld cpuset=/ mems_allowed=0 Mar 9 11:29:16 x

    kubernetes-oom-event-generator:当Pod的容器被OOMKilled后,生成Kubernetes事件

    kubernetes-oom-event-generator 容器启动时生成Kubernetes事件,并指示该容器先前已被杀死。设计控制器侦听Kubernetes API中的新事件和事件更改。 每次收到有关事件的通知时,它都会根据事件的Reason和所涉及对象的...

    Android内存回收机制

    Android内存回收机制策略 1、GC 2、lowmemorykiller GC GC是java虚拟机的内存...OOM(Out Of Memory) : Android内存管理机制及优化方法(https://www.2cto.com/kf/201805/741791.html) 简言之,即应用占用的最大内存

    lab8_oom实验说明1

    Linux操作系统的OOM (Out-Of-Memory) Killer是一个重要的内存管理机制,用于处理系统内存不足的情况。当系统资源极度紧张,无法分配新的内存时,OOM Killer会选择并终止一个或多个进程,以释放足够的内存资源,防止...

    heart_oom_protect:Erlang库可保护心脏免受Linux内核的OOM Killer的杀害

    当Linux系统面临内存不足的压力时,内核会启动一个称为“Out-of-Memory (OOM) Killer”的机制来防止系统崩溃。然而,OOM Killer可能会选择终止重要的进程,包括Erlang应用程序。针对这种情况,有一个名为“heart_oom...

    android 使用okhttp可能引发OOM的一个点

    Android 使用 OkHttp 可能引发 OOM 的一个点 在 Android 开发中,使用 OkHttp 库是非常常见的,但是在使用 OkHttp 时,我们需要注意一个可能引发 OOM 的点,那就是在签名校验中对 RequestBody 的处理。 首先,让...

Global site tag (gtag.js) - Google Analytics