命令: grep "Out of memory" /var/log/messages egrep -i -r 'killed process' /var/log 可以查看进程被kill的日志,如: --------------------------------- kernel: [1799319.246494] Out of memory: Kill process 28536 (java) score 673 or sacrifice childSep kernel: [1799319.246506] Killed process 28536 (java) total-vm:1271568kB, anon-rss:426528kB, file-rss:0kB --------------------------------- total-vm是申请使用的空间,anon_rss是实际使用的内存,file-rss是跟文件相关的内存 --------------------------------- 据我了解,进程使用的虚拟内存的大小列为" total-vm"。 它的一部分实际上已映射到RAM本身(已分配和使用)。 这是" RSS"。
RSS的一部分分配在实内存块中(而不是映射到文件或设备中)。 这是匿名内存(" anon-rss"),并且还有RSS内存块被映射到设备和文件(" file-rss")中。
因此,如果您在vim中打开一个巨大的文件,则文件rss会很高,另一方面,如果您malloc()大量内存并真正使用它,那么您的anon-rss也会很高。
另一方面,如果您分配了大量空间(使用malloc()),但从未使用过,则total-vm会更高,但不会使用实际内存(由于内存过量使用),因此, rss值会很低。
As I understand, the size of the virtual memory that a process uses is listed as "total-vm". Part of it is really mapped into the RAM itself (allocated and used). This is "RSS".
Part of the RSS is allocated in real memory blocks (other than mapped into a file or device). This is anonymous memory ("anon-rss") and there is also RSS memory blocks that are mapped into devices and files ("file-rss").
So, if you open a huge file in vim, the file-rss would be high, on the other side, if you malloc() a lot of memory and really use it, your anon-rss would be high also.
On the other side, if you allocate a lot of space (with malloc()), but nevers use it, the total-vm would be higher, but no real memory would be used (due to the memory overcommit), so, the rss values would be low.
|