Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread Display Modes
Old Jan 10, 2013, 07:06 AM   #1
macrumors 603
ArtOfWarfare's Avatar
Join Date: Nov 2007
Send a message via Skype™ to ArtOfWarfare
How Does Activity Monitor Work?

Does anyone know from whence Activity Monitor fetches all the data it shows?

Namely, I'd like to find the breakdown of CPU and RAM usage of each process running on the computer in my app.

An ideal solution would be MAS-permitted but I'd be happy with any solutions anyone has.

I'm in a similar boat to this person:


Looking at other sources, I found someone saying that the kernel keeps track of memory and CPU usage of each application.

To be clear, the data I want is exactly what activity monitor shows... I've read other places that there are five different types of memory, and I don't care that much about such details... Whatever is good enough for Activity Monitor is good enough for me.
ArtOfWarfare is offline   0 Reply With Quote
Old Jan 10, 2013, 07:14 AM   #2
robbieduncan's Avatar
Join Date: Jul 2002
Location: London
Possibly using DTrace?
robbieduncan is offline   0 Reply With Quote
Old Jan 10, 2013, 01:00 PM   #3
macrumors regular
Join Date: Aug 2008
Location: Cambridge, UK
Yeah most likely using DTrace or simply a GUI to the top command.
Ap0ks is offline   0 Reply With Quote
Old Jan 10, 2013, 02:30 PM   #4
macrumors 603
Join Date: Aug 2009
Start by looking at the man page for the 'top' command. See if it has the ability to print every specific datum you want.

If it does, then go get the source for 'top' from Apple's Darwin website, and see how 'top' gets each specific datum. I suspect 'top' uses the sysctl() function (man section 3) for a lot of things, and the various KERN_PROC mibs or names. But the best approach is to look at top's source.

If you need some datum that top doesn't display, and you can't figure out a sysctl() name to use, ask again.

Notice when running Activity Monitor that pmTool, which Activity Monitor uses to gather data, runs as root, which means you may be restricted in deploying to the Mac App Store.
chown33 is offline   0 Reply With Quote

MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
EscrowSecurityAlert on Activity Monitor? MacMan988 OS X Mavericks (10.9) 4 Feb 3, 2014 11:55 AM
Activity Monitor Help me! Dukeluke MacBook 6 Jan 10, 2014 10:46 PM
Activity Monitor PowerBook-G5 OS X Mavericks (10.9) 1 Nov 3, 2013 02:26 PM
Using Activity Monitor jj17 iMac 2 Nov 19, 2012 01:47 PM
page out in activity monitor mrdinh Mac Pro 5 Jul 31, 2012 06:32 PM

Forum Jump

All times are GMT -5. The time now is 10:05 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2015, MacRumors.com, LLC