內存相關分析

ENOMEM 錯誤碼的含義以下:
Either there is not enough memory for the operation, or the process is out of address space. 據此,有兩種出錯的狀況:app

內存耗盡

進程異常退出,看不到FATAL 信息,即使設置爲ulimit -c unlimited , 也沒有core;ide

1.確認是OOM

[root@server]# dmesg | grep oom_kill_process
[9490641.269105]  [<ffffffff81137ea2>] oom_kill_process+0x1f2/0x350
[9556122.646244]  [<ffffffff81137ea2>] oom_kill_process+0x1f2/0x350

2.如何分析是哪一個進程致使的

若是進程支持
用top 找到耗用內存多的進程;函數

3. 如何定位是哪一個線程致使的

(?)this

4.如何定位是哪一個函數致使的

地址空間耗盡

跟進連接 http://www.redhat.com/magazine/001nov04/features/vm/spa

The max_map_count file allows for the restriction of the number of VMAs (Virtual Memory Areas) that a particular process can own. A Virtual Memory Area is a contiguous area of virtual address space. These areas are created during the life of the process when the program attempts to memory map a file, links to a shared memory segment, or allocates heap space. Tuning this value limits the amount of these VMAs that a process can own. Limiting the amount of VMAs a process can own can lead to problematic application behavior because the system will return out of memory errors when a process reaches its VMA limit but can free up lowmem for other kernel uses. If your system is running low on memory in the NORMAL zone, then lowering this value will help free up memory for kernel use.線程

參考上面的說明,max_map_count這個參數就是容許在VMAs(虛擬內存區域)擁有最大數量,VMA是一個連續的虛擬地址空間,當進程建立一個內存映像文件時VMA的地址空間就會增長,當達到max_map_count了就是返回out of memory errors。這個數據經過下面的命令能夠查看:cat /proc/sys/vm/max_map_count rest

解決方法:擴大max_map_count
參考命令以下:
sudo sysctl -w vm.max_map_count=262144
vm.max_map_count = 262144code

相關文章
相關標籤/搜索