lsof
usually reports entries from the Linux/proc/<PID>/maps
file withmem
in theTYPEFD column. However, whenlsof
can'tstat(2)
a path in the processmaps
file and themaps
file entry contains(deleted)
, indicating the file was deleted after it had been opened,lsof
reports the file asDEL
.
link , conforme destacado por @don_crissti.
lsof
não pode mostrar o tamanho desses arquivos, mesmo quando executado como root. (Meu lsof
é a versão 4.89).
No entanto, se você tiver um novo kernel e um root
access suficientes, poderá ver os mapas em ls -l /proc/$PID/map_files/
e executar stat --dereference
em arquivos individuais para mostrar seu tamanho. Isso pode ser usado para inspecionar os recursos usados pelos arquivos mapeados "excluídos". Em particular memfd
s, que nunca aparecem no sistema de arquivos e são sempre considerados como (deleted)
files.
$ ls -l /proc/$(pgrep pulseaudio)/map_files | head
total 0
lr--------. 1 alan-sysop alan-sysop 64 Mar 18 23:50 562004ac5000-562004ada000 -> /usr/bin/pulseaudio
lr--------. 1 alan-sysop alan-sysop 64 Mar 18 23:50 562004cda000-562004cdb000 -> /usr/bin/pulseaudio
lr--------. 1 alan-sysop alan-sysop 64 Mar 18 23:50 562004cdb000-562004cdc000 -> /usr/bin/pulseaudio
lrw-------. 1 alan-sysop alan-sysop 64 Mar 18 23:50 7fab98000000-7fab9c000000 -> /memfd:pulseaudio (deleted)
lrw-------. 1 alan-sysop alan-sysop 64 Mar 18 23:50 7fab9c000000-7faba0000000 -> /memfd:pulseaudio (deleted)
lrw-------. 1 alan-sysop alan-sysop 64 Mar 18 23:50 7faba0000000-7faba4000000 -> /memfd:pulseaudio (deleted)
lrw-------. 1 alan-sysop alan-sysop 64 Mar 18 23:50 7faba4000000-7faba8000000 -> /memfd:pulseaudio (deleted)
lrw-------. 1 alan-sysop alan-sysop 64 Mar 18 23:50 7faba8000000-7fabac000000 -> /memfd:pulseaudio (deleted)
lrw-------. 1 alan-sysop alan-sysop 64 Mar 18 23:50 7fabac000000-7fabb0000000 -> /memfd:pulseaudio (deleted)
$ sudo stat --dereference /proc/$(pgrep pulseaudio)/map_files/7fab98000000-7fab9c000000
File: /proc/25911/map_files/7fab98000000-7fab9c000000
Size: 67108864 Blocks: 0 IO Block: 4096 regular file
Device: 5h/5d Inode: 2399078 Links: 0
Access: (0777/-rwxrwxrwx) Uid: ( 1000/alan-sysop) Gid: ( 1000/alan-sysop)
Context: unconfined_u:object_r:user_tmp_t:s0
Access: 2018-03-18 23:47:48.714061694 +0000
Modify: 2018-03-18 23:47:48.713061683 +0000
Change: 2018-03-18 23:47:48.713061683 +0000
Birth: -
Por exemplo pelo menos, era possível ver que nenhum memfd individual, pelo menos mantido diretamente por um FD ou por um mapeamento de memória, estava consumindo gigabytes sozinho. Ainda seria bom ter algumas ferramentas ou scripts melhores em torno disso.
$ sudo du -aLh /proc/*/map_files/ /proc/*/fd/ | sort -h | tail
du: cannot access '/proc/self/fd/3': No such file or directory
du: cannot access '/proc/thread-self/fd/3': No such file or directory
108M /proc/10397/map_files/7f1e141b4000-7f1e1ad84000
111M /proc/14862/map_files/
112M /proc/10397/map_files/
113M /proc/18324/map_files/7efdda2fb000-7efddaafb000
121M /proc/18324/map_files/7efdea2fb000-7efdeaafb000
129M /proc/18324/map_files/7efdc82fb000-7efdc8afb000
129M /proc/18324/map_files/7efdd42fb000-7efdd4afb000
129M /proc/18324/map_files/7efde52fb000-7efde5afb000
221M /proc/26350/map_files/
3.9G /proc/18324/map_files/
$ ps -x -q 18324
PID TTY STAT TIME COMMAND
18324 pts/1 S+ 0:00 journalctl -b -f
$ ps -x -q 26350
PID TTY STAT TIME COMMAND
26350 ? Sl 4:35 /usr/lib64/firefox/firefox
$ sudo ls -l /proc/18324/map_files/7efde52fb000-7efde5afb000
lr--------. 1 root root 64 Mar 19 00:32 /proc/18324/map_files/7efde52fb000-7efde5afb000
-> /var/log/journal/f211872a957d411a9315fd911006ef03/user-1001@c3f024d4b01f4531b9b69e0876e42af8-00000000002e2acf-00055bbea4d9059d.journal