系统还有很不少内存空间,却发生OOM是咋回事

系统还有很不少内存空间,却发生OOM是怎么回事?
本帖最后由 seai 于 2014-08-13 17:09:25 编辑
# php mycount.php
Killed

# uname -a
    2.6.32-431.el6.x86_64 #1 SMP Fri Nov 22 03:15:09 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

# tailf -f /var/log/message
    kernel: Out of memory: Kill process 14188 (php) score 508 or sacrifice child

# free -lm
             total       used       free     shared    buffers     cached
Mem:         15010      14920         90          0        318      10976
Low:         15010      14920         90
High:            0          0          0
-/+ buffers/cache:       3625      11385
Swap:            0          0          0

# cat /proc/meminfo
MemTotal:       15370896 kB
MemFree:         6339324 kB
Buffers:          283160 kB
Cached:          6304016 kB
SwapCached:            0 kB
Active:          2135472 kB
Inactive:        5339232 kB
Active(anon):    1577736 kB
Inactive(anon):  4439692 kB
Active(file):     557736 kB
Inactive(file):   899540 kB
Unevictable:           0 kB
Mlocked:               0 kB
SwapTotal:             0 kB
SwapFree:              0 kB
Dirty:              4700 kB
Writeback:             0 kB
AnonPages:        888048 kB
Mapped:           631120 kB
Shmem:           5129772 kB
Slab:            1410232 kB
SReclaimable:     330528 kB
SUnreclaim:      1079704 kB
KernelStack:        2240 kB
PageTables:        30408 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:     7685448 kB
Committed_AS:    7775268 kB
VmallocTotal:   34359738367 kB
VmallocUsed:       39188 kB
VmallocChunk:   34359699084 kB
HardwareCorrupted:     0 kB
AnonHugePages:         0 kB
HugePages_Total:       0
HugePages_Free:        0
HugePages_Rsvd:        0
HugePages_Surp:        0
Hugepagesize:       2048 kB
DirectMap4k:    15728640 kB
DirectMap2M:           0 kB

------解决方案--------------------
你的系统swap怎么是0?
------解决方案--------------------
会不会是memory_limit设置引起的,执行php --ini找到命令行加载的配置文件路径,把memory_limit值放大后试试
------解决方案--------------------
另外,你这个mycount.php脚本有没有可能真用掉10几个GB的内存啊,比如SELECT *一个超大的数据表什么的,那就得从具体的脚本代码入手解决了。
------解决方案--------------------
Process 9768, rss memory, which is the physical memory used by the process is 1589781(I believe the unit is kB) and the meantime, os only has 90MB free memory. Yes, u have buffer and cache available, but they were reserved by os for disk io. They may or may not be released for other processes. OOM killer is necessary since swap is disabled.