How do I monitor the total physical and virtual memory usage of a process and all of its descendants?
From the command line, how would I get the total physical and virtual memory usage of a process and all of its descendants (not just 1st-level children)?
This is useful when you want to monitor the memory usage of applications that are not monolithic. For instance, Google Chrome spawns a whole bunch of workers and renderers, even though to the user, it's all in only one GUI window. Another example is Firefox, which has separate processes for its plugins.
The Activity Monitor application can display the processes in a hierarchy. But I find it not good enough, for two reasons:
- It's not command-line;
- It doesn't sum the numbers for me.
Solution 1:
If using third-party applications is a possibility, I would suggest that you install the htop process monitor, perhaps from Macports. This tool extends top
with a nice layout, and most relevant for your use case, it has an arbitrarily deep thread tree view that can be turned on with the F5
key.