dmesg 命令: https://blog.51cto.com/yangzhiming/2343192
https://stackoverflow.com/questions/18845857/what-does-anon-rss-and-total-vm-mean
查看oom信息
dmesg命令:
友好的顯示log時間信息: dmesg -T
清空dmesg: dmesg -c
查看OOM: dmesg -T | grep "Out of memory"
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.
據我了解,進程使用的虛擬內存大小被列為“total-vm”。 它的一部分實際上映射到 RAM 本身(分配和使用)。 這是“RSS”。
RSS 的一部分分配在實際內存塊中(而不是映射到文件或設備中)。 這是匿名內存(“anon-rss”),還有映射到設備和文件的 RSS 內存塊(“file-rss”)。
所以,如果你在 vim 中打開一個大文件,file-rss 會很高,另一方面,如果你 malloc() 大量內存並真正使用它,你的 anon-rss 也會很高。
另一方面,如果您分配了很多空間(使用 malloc()),但從不使用它,總虛擬機會更高,但不會使用實際內存(由於內存過度使用),所以, RSS 值會很低。