How Big is that Process?
As I have, you might be tempted to think that top “VIRT” and ps “VSZ” values represent the entire size of a process, including all shared libraries and swapped-out data. Today, we learned that this can’t possibly be the case:
top - 14:41:53 up 86 days, 3:22, 3 users, load average: 13.57, 6.67, 4.00 Tasks: 162 total, 3 running, 159 sleeping, 0 stopped, 0 zombie Cpu(s): 11.7%us, 5.7%sy, 0.0%ni, 45.0%id, 37.1%wa, 0.0%hi, 0.4%si, 0.0%st Mem: 8102704k total, 8056796k used, 45908k free, 9004k buffers Swap: 4008208k total, 1274816k used, 2733392k free, 2075736k cached PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 1472 mysql 15 0 19.8g 4.0g 7440 S 1 52.1 1374:57 mysqld
You can’t have a 19.8 gig process on a machine with only 12 gigs of memory! One anonymous commenter of Virtual Threads: Understanding memory usage on Linux suggests a plausible explanation: memory fragmentation.