MacOS – What kind of “messages” does Activity Monitor track with the “Messages Sent” and “Messages Received” columns

activity-monitormacos

In Activity Monitor on OS X, it is possible to add additional columns to the process list view. Two columns available in that list are "Messages Sent" and "Messages Received", which show up as "Sent Msgs" and "Rcvd Msgs", respectively. Witness:

Portion of Activity Monitor window showing "Sent Msgs" and "Rcvd Msgs" columns

What kind of "messages" is Activity Monitor referring to?

When I saw "message", I thought at first of Objective-C "messages" that are dispatched with objc_msgSend(), but I can't see how those would be tracked by the operating system since most of those messages would be internal to the process itself. A debugger might track those kinds of messages when attached, but I can't see the OS doing it all the time — very high overhead.

So I am guessing those are heavier-weight messages. Are they a form of RPC between processes? Or, are those messages calls from user-land into the kernel? Seeking definitive references. Thank you.

Best Answer

Those numbers match the Mach messages in/out counts, so you seem to be correct in not interpreting them as the objc_msgSend counts.

You can learn more about higher level message counts by firing up Instruments (part of the freely downloadable Xcode toolset) and digging into a specific application to see what messages are being sent and when.

Xcode Instruments screen shot

It can filter all allocations as well as allocations relating to ObjC and you can dig into much lower level details than just message send counts. The canonical documentation that is part of Xcode will help you make sense of these statistics and how they relate to Activity Monitor.

Specifically, search for NSObjCMessageLoggingEnabled and objc_msgSend in the Mac OS X Debugging Magic - Tools Guide portion of the Reference Documentation to get at the objC counts.

Search for mach message in Xcode and look for the IPC/Message Queues section of the Kernel Programming Guide for mach message queue details and what makes them up. They are much lower level IPC kernel traffic as you have surmised.

You probably can find it on developer.apple.com as well, but having the documentation local from within Xcode has many advantages.