Handle growing SystemUIServer memory usage

Sep 20, '10 07:30:00AM

Contributed by: name99

iStat is a great program for keeping track of your system by displaying menulings showing CPU usage, memory usage etc. In Mac OS X menulings (also called menu extras) are managed by a program called SystemUIServer.

iStat appears to have a memory leak where over time, the REAL memory used by SystemUIServer grows basically without bound. Memory usage that should be around 40MB balloons to 300MB then to 1.3GB over a few weeks of never rebooting. This would be bad enough if it was the virtual address space that was being used up this way, but this is real memory, causing real memory pressure and real swapping.

Obviously the ideal would be for Bjango to get on the case and fix this bug. Since they appear unwilling to do so, I have come up with a workaround.

The following facts are relevant to the workaround.

To make this all happen is not too hard. You need to create a launchd script, I called mine my.SystemUIServer_cleaner.plist, and populate it as follows:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>Label</key>
  <string>my.SystemUIServer_cleaner</string>
  <key>ProgramArguments</key>
  <array>
    <string>killall</string>
    <string>SystemUIServer</string>
  </array>
  <key>StartCalendarInterval</key>
  <dict>
    <key>Hour</key>
    <integer>4</integer>
    <key>Minute</key>
    <integer>0</integer>
  </dict>
</dict>
</plist>
Put this in /Library/LaunchAgents, and make sure it is owned by root:

cd /Library/LaunchAgents
sudo chown root:wheel my.SystemUIServer_cleaner.plist


This file will only be noticed by launchd and kick in automatically when you logout then login again. If you don't want to do that, but do want it to start working right away, you can manually tell launchd about it using:

sudo launchctl load /Library/LaunchAgents/my.SystemUIServer_cleaner.plist

[crarko adds: I haven't tested this one. This would be applicable to managing runaway SystemUIServer memory in general if you observe it, and not just for iStat. It's also a good example of a simple launchd script.]

Comments (18)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20100918163629993