Fixing high memory usage caused by mds

Screenshot of activity monitor on Mac OS X showing mds with high memory usafe

Recently my Mac Mini has been running very slowly, with some programs freezing for as much as several minutes. I pruned the list of items that were running on startup but this didn’t seem to make much difference.

So I opened Activity Monitor (the OS X equivalent of Task Manager) and found a process called ‘mds’ was consuming huge amounts of RAM and virtual memory. MDS is the process which builds an index of your disks for use by Spotlight, the tool that lets you search your drives, and also by Time Machine for backups. Sometimes MDS requires a fair amount of RAM, but it was using almost 2 gigabytes of virtual memory and almost a gigabyte of RAM in my case. I only have 4 gigabytes of RAM in total, and so this was causing major problems as OS X had to regularly swap data between RAM and the paging file.

I’d tried looking into this before and got nowhere. Most of the results in Google were discussions on Apple’s support forums, which were devoid of any real solutions. But eventually I found this post on iCan’t Internet which actually had a solution.

Firstly you should run Disk Utility. Repair your hard disk, and also repair the disk permissions. This may fix your problem, but it didn’t in my case so I moved on to the next step.

Open up Terminal, and type in the following command: sudo mdutil -avE . This runs a tool called ‘mdutil’, and tells it to completely rebuild Spotlight’s index. It turns out that the index on my hard disk had got corrupted somehow, and this was causing problems with the ‘mds’ process. It took a while for the command to run, but afterwards a huge amount of RAM and virtual memory became free. Unsurprisingly, my Mac ran much more happily after this.

Hopefully if you’ve have the same problem this will help. It has certainly breathed new life into my increasingly sluggish computer.