Managing Spotlight and Memory Usage


Apple Logo

Over the weekend, I reloaded Leopard. If you remember, I was forced to upgrade to Leopard by a bad Tiger update a few months ago. My preferred method of upgrading is to wipe the disk, do a fresh install, and then restore my applications and personal files from backup. Due to the circumstances of the situation I was in, I didn't get to do that. I decided that the three day weekend presented the perfect opportunity.

The install and restore went fine and I was soon running a squeaky fresh copy of Leopard.

I'm in the habit of running Activity Monitor to see where the CPU and memory are being used and I noticed that mds, the utility that manages Spotlight, was taking almost 250Mb of RAM. Now, I don't use Spotlight enough to justify it taking one quarter of a Gig of memory, so I investigated. Here's what I did.

First, since I'd just reinstalled, I decided to blow away the old index and do a new one. I did this at the terminal:

bash> sudo mdutil -i off /Volumes/Windley

bash> sudo mdutil -E /Volumes/Windley

bash> sudo mdutil -i on /Volumes/Windley

The first command turns indexing off for a given volume--in this case my boot volume. The last command turns it back on. The middle command erases the index for the named volume. As soon as I issued the last command, the system started rebuilding the index. That took a few hours.

Once the index was rebuilt, I restarted mds with the following commands:

bash> sudo launchctl unload \\\\
      /System/Library/LaunchDaemons/com.apple.metadata.mds.plist

bash> sudo launchctl load \\\\
      /System/Library/LaunchDaemons/com.apple.metadata.mds.plist

When mds restarted it didn't use much memory at all. Each call to Spotlight increased its memory usage, but it's no where near 250Mb. I've noticed that OSX applications tend to hold memory until another application needs it, so sometimes you can look full, but still have plenty of memory.

mds is fluctuating between 30 and 100Mb now. That's still a lot of memory for something I rarely use, but it's manageable. If you want to completely disable Spotlight in Leopard, add the -w switch to the launchctl unload command in the last code block to write the configuration back out to disk. Then don't run the launchctl load command. That turns off mds completely.

As an aside, the reason I don't use Spotlight much is because I love Quicksilver. Here's a brief tutorial on Quicksilver.


Please leave comments using the Hypothes.is sidebar.

Last modified: Thu Oct 10 12:47:18 2019.