Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

See a program's memory usage in its window title System
As many of you will have noticed, Safari often seems to get itself into a state where it starts to take a lot of memory. I'm not yet convinced that this is technically a memory leak (where an app has lost track of memory that it allocated), since it might just be that Safari is misguidedly caching too much info about previously viewed pages or whatever.

But it certainly is the case that, at times, Safari starts to take much more of my precious RAM than I want it to. I don't mind too much if it is taking 100MB if I've been looking at graphically-rich pages, but I expect it to be a lot less than that most of the time. And if I notice that Safari is taking up much more than 100MB of real memory (e.g. by looking at Activity Monitor), I will quit and re-launch it in order to conserve RAM.

So I wrote an AppleScript that monitors the RAM usage of Safari (or other apps) and displays it (in megabytes) in the title of the frontmost window. The AppleScript pops up an alert dialog if the Safari memory usage exceeds a specified amount (currently 100MB). There is also an option to use Growl for these warnings. If Safari's CPU usage exceeds 10%, the CPU usage is also shown in the title bar.

To use this AppleScript, you need to copy and paste it into Script Editor, and then save it as an application bundle, being sure to click on the Stay Open checkbox. After that, you run it like any application -- e.g. by double-clicking its icon. The initial version of this script was posted to this thread on the MacOSXHints forums, and has benefitted greatly from suggestions made there by 'NovaScotian,' 'bramley', and 'mark hunte.'

[robg adds: To get this to compile, I had to download Growl, so that Script Editor would find the Growl helper app. After that, it worked as described, though in Mail, the RAM usage seemed to come and go somewhat randomly.]
  • Currently 3.17 / 5
  You rated: 5 / 5 (6 votes cast)

See a program's memory usage in its window title | 17 comments | Create New Account
Click here to return to the 'See a program's memory usage in its window title' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
See a program's memory usage in its window title
Authored by: wgscott on Jan 05, '07 07:56:38AM

I'm really impressed with this. It works great.

My hint is that you READ the applescript itself before posting it does not work. You need to change a parameter to run it from the script editor, and you can tweak the thresholds and specify the applications to be monitored.

Apart from its function, it looks like a great applescript to learn from. Lots of new stuff for me in here.

Thanks to the author for writing it and making it available.

[ Reply to This | # ]
See a program's memory usage in its window title
Authored by: thwaite on Jan 05, '07 09:02:02AM
I've happily used Rogue Amoeba's "MemoryCell" menu-bar extra for years to provide a stable & unobtrusive reading of RAM used by each program.

MemoryCell and its source are freely available. An Intel-compatible version is in beta. All at

[ Reply to This | # ]
See a program's memory usage in its window title
Authored by: bzlman on May 15, '07 03:39:23PM
Even better, check out MenuMeters, also free, that shows a colored bar (ala Slim Battery Monitor) for RAM, CPU, Memory, and/or Network usage as you choose (a separate bar for each).

Been around since System 7

[ Reply to This | # ]

See a program's memory usage in its window title
Authored by: operator207 on Jan 05, '07 09:04:11AM

Works great over here. I added OmniWeb and Vienna to the script and they seem to work fine. Thanks for the script!

[ Reply to This | # ]
See a program's memory usage in its window title
Authored by: watts on Jan 05, '07 10:22:23AM

Be careful, Growl will occasionally start to gobble memory too. I have an application that calls Growl a lot (sometimes several hundred times an hour) and after a few hours of this GrowlHelperApp will have gobbled upwards of a gig of RAM

[ Reply to This | # ]
See a program's memory usage in its window title
Authored by: watts on Jan 05, '07 10:37:12AM
off topic, but to avert the inevitable flames from growl lovers,

[ Reply to This | # ]
Understanding Activity Monitor
Authored by: chucky23 on Jan 05, '07 06:09:07PM

"after a few hours of this GrowlHelperApp will have gobbled upwards of a gig of RAM"

No. In your screenshot, GrowlHelperApp has gobbled up a bit more than 100MB of RAM.

The useful column in Activity Monitor is "Real Memory", not "Virtual Memory".

[ Reply to This | # ]
dealing with GrowlHelperApp memory leaks
Authored by: hayne on Jan 05, '07 11:54:52AM

If you find that memory leaks with GrowlHelperApp are causing a problem, you could perhaps deal with it by writing a modified version of the AppleScript of this hint to monitor GrowlHelperApp's memory usage and to restart it when it exceeded a certain amount.

Of course this could be done for any app.
I decided not to automate the restarting of memory hogging apps since sometimes you need to finish what you are doing before restarting the app.

[ Reply to This | # ]
Comment or Remove Growl from the script's functions
Authored by: gabester on Jan 05, '07 11:32:11AM
For some strange reason, I'm scared of Growl...

So I simply commented out areas starting with:
tell application "GrowlHelperApp"

I commented out lines until I had commented out following "end tell"

There are two functions to comment: displayWarningViaGrowl and registerWithGrowl. You can search for and comment out those lines (or simply remove them) and the rest of this script will work fine.

[ Reply to This | # ]

See a program's memory usage in its window title
Authored by: dustin.cook on Jan 05, '07 07:30:00PM

Can someone tell me how to edit this so that Growl is taken out of the picture entirely? When I try to delete the growlhelperapp and displaywarningviagrowl, I get an error when i try to save, and script doesn't function properly (it shows the memory usage in the apps up until I click on something in the app.

Would be much appreciated.


[ Reply to This | # ]
10.4 Only Notes!! See a program's memory usage in its window title
Authored by: Frederico on Jan 05, '07 10:11:27PM

I would kindly ask the authors of all these awesome scripts of late to *PLEASE* make note of system version compatibility! I got hit with a surprising number of support calls today wondering why they could not make this script work, even after installing Growl.

Please, please, please, note at the top of the script under which version of the Mac OS and AppleScript version it was authored and tested; please note whether or not you think it should, might, or will not, to the best of your knowledge, run under older versions; i.e., if you write it under 10.4.8, and do not have older versions, especially major versions (10.3, 10.2, 10.1) to test with, make a note of that fact.

This script utilizes numerous 10.4-only functions, and fails, unfortunately, under older systems where it would probably be more useful; e.g. older hardware with limited RAM which cannot run, or cannot be cost-justified to upgrade to, the latest OS; thus things like RAM usage display would be far more valuable.

It looks like I could rewrite this to perform similar function under at least 10.3; if I do, I will post it here.


[ Reply to This | # ]
Authored by: hayne on Jan 05, '07 11:31:59PM

I had no idea that the script was using some functions that are only available in 10.4 or later. I don't have a 10.3 system to test on.

Which functions are causing trouble in 10.3 ?

[ Reply to This | # ]
See a program's memory usage in its window title
Authored by: johnsawyercjs on Jan 06, '07 02:00:48AM

To get this Applescript to not use Growl, I believe all you have to do is change the "true" to "false" in the line near the beginning of the script:

property useGrowl : false

[ Reply to This | # ]
See a program's memory usage in its window title
Authored by: johnsawyercjs on Jan 06, '07 02:08:20AM

I also find it interesting that when you try to compile this Applescript, that Script Editor asks you to find GrowlHelperApp, which is a resource inside the Growl prefpane, not the Growl prefpane itself. I wonder if selecting just the Growl prefpane would make Script Editor happy--I don't know, since I didn't try selecting the Growl prefpane when Script Editor asked me to find GrowlHelperApp--I just canceled the request, changed the 'property useGrowl :' line to false as I describe above.

[ Reply to This | # ]
See a program's memory usage in its window title
Authored by: mark hunte on Jan 06, '07 03:51:08AM
If you look on the thread Hayne provided above (post 67 ), there is a version that looks to see if growl is installed first.
It will not ask you to look for growl, but if you have the growl property set to true,
it will put a small note in your warning.


[ Reply to This | # ]

Just to be sure I understand...
Authored by: riktexan on Jan 07, '07 06:44:07PM

Just to be sure I understand...When I install this script (which I have done successfully, accompanied by Growl) I will know when Safari is gobbling up too much RAM. That means it's slowing things down, right?
When that happens and/or I get the alert, I quit then restart Safari to release all that RAM.
I know enough to understand the problem but not it's technical details. I just wanted to verify I'm on the right track when I see the info at the top of the window.
Rick in Maine

[ Reply to This | # ]
RAM usage not necessarily connected to slowdowns
Authored by: hayne on Jan 07, '07 11:23:00PM

Just because Safari (or any other app) is taking a lot of memory does not necessarily mean that it is causing a slowdown of your Mac.
What will slow down your Mac is if you are running enough memory-hungry apps and keeping them all active so that collectively they have a need for more memory than you have (physical RAM).

The reason why it will slow down your Mac is that in this case, the system is forced to swap out some of your apps' memory to disk - and disks are extremely slow compared to all other computer components. The diagnostic sign for when this is happening is that you see a large number of "page-outs" listed in the System Memory tab at the bottom of Activity Monitor.

On the other hand, suppose you have 1 GB of RAM in your Mac and Safari is taking 100 MB but you don't have any other apps that are taking anywhere near that much memory. In that case, you are unlikely to be running out of RAM to the extent that the system has to swap to disk. So even though Safari is taking up lots of RAM, there is no problem at all.

Note too that the system considers unused RAM as wasted RAM, so it tries to find a use for almost all of your RAM, keeping only a little bit as a reserve. If the apps you are running don't demand a lot of RAM, the system will use the RAM to cache some frequently-used disk files (since disk access is much slower than RAM). So just because there is a relatively small amount of "free" memory listed doesn't mean there is a problem - that is normal (the system making use of the RAM you have).

[ Reply to This | # ]