Ugly Bug in Mac OS X Address Book?

I don’t have an official bug report for this but I’m seeing a very ugly bug in Mac OS X Address Book or some part of the applications that work with its data. In short, it seems that in some situations Address Book can duplicate all the images associated with contacts, multiple times.

I keep really important data in my Address Book and as a result I do a weekly manual backup in addition to Time Machine backups. Look at the size of my weekly backups in this screenshot.

Address Book Backup File Sizes

In a two-week period the duplication happened multiple times. From October 24 to October 30 it happened twice increasing the size of all images from 17 to 34MB and then again from 34 to 64MB. It happened again doubling from 64M to 120MB! The culprit here are the images associated with contacts and stored in ~/Library/Application Support/AddressBook/Images. This behavior is on my Mac Pro which is synchronized with MobileMe to my MacBook Pro and iPhone. However, the error isn’t the same on all synchronized Macs. Looking in the images directory on my Mac Pro there is 130.5MB of data with 8,782 files.

images folder on mac pro

The same folder on my MacBook Pro is much smaller at 17.9MB with 1,222 items, however even that is too many.

images folder on macbook pro

To put this into context my address book has 979 cards in it and I tend to associate an image with most entries. Sadly when I look at the images directory manually even the one on my MacBook Pro has duplicated once.

It is very hard to figure out what is going on that directory since the file names are all just random GUIDs. The best way I’ve found is to sort by file size which usually puts the duplicate files right next to each other. It seems likely that these extra files are just ignored, but they are taking up a lot of space and I worry will lead to eventual corruption.

If you use MobileMe I’ve found a way to fix this. Do a Reset Sync data and choose to replace your content on your computer with the data from MobileMe. After doing that my images directory is healthy at 11.9MB with 757 items in it.

fixed-images-directory

Strange and concerning behavior. Does anyone else see this behavior?

11 thoughts on “Ugly Bug in Mac OS X Address Book?

  1. I discovered this problem today, after restoring my Address Book following a clean wipe of my computer. Only 109 of my contacts have photographs attached to them, but ~/Library/Application Support/AddressBook/Images was showing well over 5100 files in it. Using QuickLook confirmed that there were excessive copies of each image.

    I spent a couple hours trying to sort this out, and I finally figured out what’s happening. Address Book duplicates a picture whenever a contact is duplicated. It doesn’t just reference the original image, it has to create a whole new copy for some ridiculous reason.

    A contact is duplicated every time it gets assigned to a new Group. Basically, the contact’s vCard exists individually, and a copy is inserted into the Group vCard. If a contact’s vCard is assigned to multiple groups (eg Work, Contractor, Project Managers) then Address Book duplicates that contact’s images for each of those groups (in addition to the original image being referenced by the single vCard entry).

    So, for example, my 109 contacts with images are all assigned to the Friends group. That results in 218 images in my folder (one each for the individual vCards, and a copy for the Friends group vCard, which can be viewed in the Metadata folder). If I then also assign half of those to the Classmates group, I’ll end up with 273 images.

    Here’s the terrible part: even if you later decide to delete a contact from a group, Address Book will not delete the copied image; it will just abandon the image as an orphan file. So if you have the misfortune (as I do) of having dynamic Smart Groups that constantly add and subtract contacts from the group, well you end up with massive amounts of duplicated images. My 109 contacts that I had been shuffling around to various groups these past few years blossomed into well over 5000 copies!

    Lastly, whenever you update the image of your contact to a newer pic, Address Book will also orphan the previous image and abandon it in the Images folder. For some reason it doesn’t delete images that are no longer being referenced, and so I discovered really old pics of various people whose images I dutifully updated over the years. Worse is that the cryptic file names make it virtually impossible to sort out that mess!

    I ended up exporting each group as a vCard group (dragged to my desktop), quit Address Book, and then sent ~/Library/Application Support/AddressBook/ to the Trash. Restarting the app got me a clean slate where I reconstructed my groups, and subsequently dragged each vCard group back to the appropriate group in the app. Checking my Images folder confirmed that I now have only 218 image files.

    Unfortunately, this is only a temporary solution. Address Book begins duplicating those images again soon enough. At one point today, I noticed my Image folder grew to 285 images for some reason that I can’t figure out (did not move/change any contacts since I cleaned it earlier).

    Hoped that helped. Sorry for the long post. Don’t know if you already figured all that out.

    • Update:

      Sorry, please ignore the penultimate paragraph regarding my Images folder growing to 285 images for no reason. That didn’t actually happen; my folder still only has 218 image files. I had glanced at a wrong folder when I typed that out. <_<

  2. I found out because on MobileMe all contacts showed up from 2 up to 8 times. I made a backup of my Address book on my Macbook Pro and then deleted all contacts on my Mac, MobileMe and iPhone. Reinstalling from the backup didn’t work. Then I saw the backup was 2,58GB! A backup from 2 weeks ago was 30 MB. I used Time Machine to get the data back and I stopped it when I saw it was trying to put 55.000 images back on my mac. Now I used time machine to put everything but the images folder back. I used an older time machine copy for the images. The explanation given Wrath doesn’t work for me because After years of using the amount of images is maybe to high but this exploding to 55.000 imges happened last weeks. In this holiday time I hardly changed anything in my Address book. Could it be recent The Mobile Me work over?

  3. This happens to me just with syncs with my iPhone thru iTunes (I don’t have a MobileMe account).

    In previous versions of Address Book we had a debug menu that cleaned these orphaned images, but this hidden menu has disappeared with most recent versions (Snow Leopard’s)

    I once took my vcards on a previous version of address book. it cleaned all and I went back to Snow leopard with this cleaned archive and reimported it.
    But all my 50 or so personalized ringing tones were not associated to their contact. I had to do it again one by one…

    Apple should correct this bug

  4. I have noticed this bug too!
    I have an HTC phone and I synchronize it with Lion’s Address Book via SyncMate by Eltima Software. Year ago I noticed that every time I sync, my address book grows by size and file count. After some trials and tests I found that there were duplicates in the Images folder and they kept replicating after each sync! Nasty indeed! I blamed the sync software, which was beta at that time and after complete wiping and syncing again, the problem disappeared.
    Recently, after reinstalling Lion, I synced my phone again and the problem started again! I am pissed off, cause Address Book is getting slower and slower every time and backing up is starting to be a problem.

    I have a strong intention to make a tool for repairing the Lion’s Address Book, but I need your support with testing and more information about the behavior. Any comments and suggestions are welcome!

    P. S. Does someone know if this bug has been documented already? Is there any official information about it?

  5. Same issue and over 7000 files/images in the app support/address book although i only have 367 contacts. Really annoying. the folder size is 95MB which is ridiculous. Mountain Lion 10.8.4 (not syncing to iCloud). Thanks. Luds

  6. I made an alpha version of a tool that removes the duplicates and clears the address book. If someone is interested, I can send them for testing and feedback. For me its working fine – no contact is lost so far, no duplicate has been missed. If you are interested, write me at kfilipoff@gmail.com and I can send it to you for testing and feedback.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>