6

Is there a way to see memory usage per app in macOS? That is, I want to see the total memory consumed by each app, including its child processes.

The Activity Monitor shows memory usage by process which makes it hard to determine, for example, how much memory the Chrome app is using, since it spawns multiple processes.

  • For Chrome specifically have you used its built in task manager? – Atari911 Jun 12 '15 at 4:55
5

Activity Monitor > View > All Processes, Hierarchically ought to do it, with a bit of scrolling...

enter image description here

  • 3
    This seemed promising. But on checking I found that the it still doesn't show the total memory being used by an App. It's just individual processes grouped under the parent process. (You can verify that for the Safari and Mail apps shown in your screen shot -- the memory usage doesn't add up). In fact, on my Mac currently, the Chrome.app has child processes that individually seem to be using more memory than the parent Chrome.app process. – Himanshu P Sep 7 '14 at 8:42
  • 1
    Without knowing for certain, I'd say that you would need to add up all the child processes, then add the parent, to get the true total - I think you're assuming the parent IS the total. I would assume it's not. A simple test for that would be to check the kernel task total, which is nowhere near the sum of it's sub-processes. – Tetsujin Sep 7 '14 at 8:44
  • 1
    That's exactly what I said above... this view doesn't show the total memory usage per app. I am looking for a method that does. I can't be bothered to add 30 3-digit numbers each time I want to see how much memory chrome is using. – Himanshu P Sep 7 '14 at 9:28
  • 1
    Then I think you're out of luck - they are child processes, subordinate but separate to the main process. My fairly decent Google-Fu finds no utility that will add them up automatically. Maybe someone else can find one... – Tetsujin Sep 7 '14 at 9:59
  • 7
    It's not that simple, processes can share memory, so total memory is not as easy as add all memory from the children. Plus, there's virtual versus real memory. It's a slightly complicated beast. :-( – chmac Dec 12 '14 at 15:31
1

I'm totally a fan of htop which can be installed via Homebrew, which is more powerful and flexible than the activity monitor.

Run it in a console, I think it's straightforward.

1

If you're not fussed about having a nice GUI and have a python distro installed, you can use psrecord.

  • Open Terminal
  • Install with pip install psrecord
  • Get the Chrome PID (can use activity monitor)

Activity Monitor

  • Run psrecord, with the --include-children flag, providing the PID as an argument

I would recommend specifying some duration (60s in my examples) otherwise psrecord would continue running until Chrome is terminated.

psrecord will record the CPU usage (%) and Memory usage (MB) which you can have it output as either a plot:

psrecord 95639 --plot chrome.png --include-children --duration 60

psrecord plot

or a log file:

psrecord 95639 --log chrome.txt --include-children --duration 60
# Elapsed time   CPU (%)     Real (MB)   Virtual (MB)
       0.000        0.000     1672.918    65500.004
       0.078        2.400     1672.922    65500.004
       0.161        3.200     1672.926    65500.004
       0.245        3.400     1672.926    65500.004
       0.329        4.300     1672.930    65500.004
       0.410        3.400     1672.934    65500.004
       0.492        3.900     1672.938    65500.004
       0.580        2.700     1672.941    65500.004
       0.667        3.200     1672.945    65527.895
       0.748        3.100     1672.945    65500.004
       0.830        3.200     1672.949    65500.004
       0.911        3.000     1672.953    65500.004
       0.993        3.200     1672.953    65500.004
       1.074        3.500     1672.957    65500.004
0

There is USS in MacOS available.

The USS (Unique Set Size) is the memory which is unique to a process and which would be freed if the process was terminated right now.

psutil>4.0 Python library can access it

Here is I would use it

sudo python3 -c "import psutil;print(sum(p.memory_full_info().uss for p in psutil.Process(pid=292).children())/1024/1024);"

where pid=292 is PID of most outer process from Activity Monitor.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .