Page History

Debugging System Problems

Mark George edited this page on 30 Apr 2022

Clone this wiki locally

List open files by process

The lsof command will show all files that are open for each process. The following will aggregate the results into a table that shows the number of tiles opened per process:

lsof | awk '{print $2,$1}' | sort | uniq -c | sort -r -n  | head

The first column is the file count, the second is the PID, and the third is the process name. Works in both Linux and macOs.

Find processes listening on ports

ss -plunt

or

netstat -plunt

ss is generally preferred over netstat (netstat has been deprecated on Linux for a long time).

Note the macOS version of netstat does not have these options. The closest we have in macOS is:

lsof -iTCP -iUDP -nP

Finding heap size of Java process

jcmd # will report PID of all Java processes
jcmd <pid>  GC.heap_info | grep -oP "heap *total .*? used .*? "