Tuesday, February 26, 2008

Gmail IMAP + Apple Mail + lots of messages = Constant disk activity

January 21, 2009 – See update at the bottom for a solution to this issue.

I am a long time Gmail user, but have started using Apple Mail with Gmail over IMAP just a few weeks ago. Lately I noticed that:
  1. The disk activity is almost constant while Mail is running.
  2. Mail is constantly synchronizing and downloading messages from the

The almost constant disk activity is the most annoying issue, as all the applications feel sluggish when Mail is heavily using the disk, as if the machine was swapping. I can see the constant activity of Mail with fs_usage -w -f filesys Mail.

Message synchronization is causing lots of downstream network traffic (constantly about 20-30 KB/s). As annoying as this is, with a pretty good connection, this level of network traffic doesn't have as much immediate impact as heavy disk activity.

A few data points:

  • My All Mail contains more than 110,000 messages, about 2.4 GB or 35% of the Gmail quota.
  • My ~/Library/Mail folder weighs a little more than 5 GB.
I haven't found any good solution to this issue yet. If you also have this problem, here a couple of workarounds:
  • Exit Mail when you are not using it. (I had to state the obvious.)
  • To avoid exiting and starting Mail, you can stop the process and resume it. To stop it run killall -STOP Mail, to resume it run killall -CONT Mail. Some applications don't like being stopped and resumed; I haven't noticed any negative side effects with Mail, but use this at your own risk.
And of course, if you have a hint or advise, please post a comment here. I will make sure to update this post if I hear about a solution.

A Solution
Go to the Mail.app preferences. Under Accounts, go the Advanced tab. Then, in the Keep copies of messages for offline viewing drop-down, select Only message I've read.
This will drastically cut on the amount of data that Mail.app stores locally, and it solved the slowness, high disk activity, and hanging issues I had with Mail.app. Of course, this method has a few downsides:
  • You won't be able to use Spotlight to search through the body of your messages. (Which is fine for me, as I found Spotlight to create other performance problems, and I had it disabled anyway.)
  • You won't be able to access some of your emails when offline. (The next time you do email on a flight, you might find that some emails you haven't already read have not been downloaded.)
  • Mail.app will only download the body of a new message when you click on it, which adds a little lag. (Before, Mail.app was downloading new messages in the background, so when you were clicking on a new message, that message was already there and no network activity was necessary to show the message. Ideally, I'd like to tell Mail.app "only download messages that arrive in my inbox".)


Julien said...

You can unsubscribe to the All Mail folder. With 11k messages, it is pretty much useless as a flat folder. Then you use the web interface (and search!) to access old messages...

Alessandro Vernet said...


Mail doesn't seem to have this concept of subscribing to folders, like Thunderbird does. So all the folders you have on the server show up automatically in Mail. And even if I wouldn't want to browse the All Mail folder, the fact that all the emails are downloaded makes them searchable locally through Spotlight (and I would assume Google Desktop, which I haven't tried). If you often search for messages, like Gmail got me used to, this is definitely a benefit.


Sathish said...

Can you tell where can i download the Apple mail client???

Alessandro Vernet said...

The Apple Mail client is only for Mac OS X. And if you have a Mac, you already have Apple Mail, as it comes with the OS. You can find it in /Applications/Mail.app.


BlindCripple said...

Did you ever find a solution? I have recently started using the IMAP protocol too but I really don't want to have to download the entire All Mail folder. I also don't want to move away from Mail.app. I can see the benefits of having a copy locally, but telling Mail not to download the attachments doesn't seem to have any effect on it...

Where to from here?

Alessandro Vernet said...


Yes, I found a solution. I just added it to that blog post (scroll down to the end of the post). It has a few downsides, which I described there, but all in all it makes Mail.app really usable for me.


John B said...

I changed internet providers a couple of months ago.
I went to an extremely high speed connection with a 100gb limit.

My first bill came in at 165gb. I couldn't figure out what it was but have now tracked it down to Mail <-> Gmail activity. For some reason it was sending thousands of messages back and forth.

I followed your instructions and all of a sudden, disk activity and bandwidth usage have really gone done.

I'm convinced that something is screwed up that's causing all of these files to go back and forth but have found nothing on the net (aside from your great solutiom for putting a stop to it).

Thanks for the suggestion

Andrew said...

You can "unsubscribe" to a folder locally via the "Labels" settings page on Gmail. This article describes it well:

Alessandro Vernet said...


Yes, unsubscribing to folders, especially "All Mail", is one way to reduce the strain on Mail.app. But doing so you loose some of the advantages of using Mail.app, in particular that all your email is available locally and offline.

I should note that this hasn't been a problem for me since I upgraded to Snow Leopard. In fact, being able to use Mail.app in full, with all my email available locally and indexed, was a great improvement.

Anonymous said...

Unfortunately, the "Only messages I've read" option didn't work for me. I'm experiencing this behaviour on a mac mini and an imac. The imac does this in 10.5 and 10.6 and a restart of Mail would solve the problem. Since the upgrade to 10.6, the mini now hogs resources relentlessly.

Alessandro Vernet said...

You are saying that enabling "Only messages I've read" is not enough to make Mail.app usable. How much data do you have in ~/Library/Mail? If you already have a lot of data there, just enabling the option won't help. You'll have first to remove everything you have there (at your own risk; do a backup!) and then setup the mail account again, enabling that option.

Barry said...

"If you already have a lot of data there, just enabling the option won't help."

I've about 10MB in there. I also think a lot of people have this problem but don't realise it. I only became aware of it through iStat.