Tip 915: Compact Now Every Time you Exit Outlook

A reader wanted to know if he could configure Outlook to automatically compact the pst every time he closes Outlook.

Yes, this is possible, using the PSTNullFreeOnClose registry key. This can lengthen the time it takes Outlook to shutdown and if Outlook is forced closed during the compaction process the data file could become corrupt. If you use both this key and the option to empty deleted items on exit, Outlook will take much longer to exit.

However, this setting can be useful to security conscious users as compacting removes all traces of deleted messages, making it impossible to recover the mail.

How Outlook works: when you delete an item and empty the deleted item folder, the messages (and other items) are removed from the index but left in the data file. The space used by these deleted messages is called “white space”.  Until Outlook recovers this space, it may be possible to recover deleted messages using recovery software.  Outlook will automatically compact the data file when the “white space” reaches around 20% of the data file’s size and the computer is idle. Because it runs as a background service, it can take days for Outlook to fully compact the pst file. (This is a great reason to keep Outlook open when the computer is running.)

If you deleted a lot of messages and don’t want to wait for Outlook to get around to it, you can recover the free space by running Compact Now.  To do this, right click on the top level of the data file and choose Properties, then click the Advanced button and Compact Now. Keep in mind that it can take a long time to compact a large data file.

Compact the pst at anytime using Compact Now

If you want to force Outlook to return this free space every time that you close Outlook, you can add PSTNullFreeOnClose to the registry.

Outlook 2010

HKEY_CURRENT_USER\Software\Microsoft\Office\14.0\OutlookPST
DWORD: PSTNullFreeOnClose
Value: 1 = compact on close;  0 = don’t compact

Outlook 2007

HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\OutlookPST
DWORD: PSTNullFreeOnClose
Value: 1 = compact on close;  0 = don’t compact

Outlook 2003

HKEY_CURRENT_USER\Software\Microsoft\Office\10.0\OutlookPST
DWORD: PSTNullFreeOnClose
Value: 1 = compact on close;  0 = don’t compact

This key was introduced in an update for Outlook 2000 and works in all versions of Outlook that are updated with the latest service pack.

Set the PSTNullFreeOnClose reg key to 1 to compact on every exit

This key works on both pst and ost files. With the value set to 1, deleted data is removed when you close Outlook. When it’s set to 0 or deleted, the data file will not be compacted on close.

Note that the first time you close Outlook after making this change, it may take a long time for Outlook to close.

Don't want to edit the registry? We have reg files you can download and run:

Outlook 2010Outlook 2007Outlook 2003

Published September 22, 2011. Last reviewed on June 11, 2013.

  • Pingback: Set Outlook to Compact on Close

  • http://showmehowcomputers.com Sherry Bowers

    This was extremely helpful. I had not realized that emptying my deleted folder left white space in the file. Now I understand the importance of compacting. I would definitely like to pass along this tip and a link to your site if that is acceptable to you.

    Wishing you Happy Holidays,

    Sherry Bowers

  • Sukumar Devrukhkar

    Thanks for the insight.

  • Chris

    Was this done in Windows 7 or Windows XP? Does it perform differently depending on the OS?

  • http://www.outlook-tips.net Diane Poremsky

    No, it is not affected by the windows version.

  • Stephane

    This does not compact the .pst file, but it «shreds» the deleted messages, so you cannot recover them for security reasons. I have tried it, and my PST was bigger after closing.

  • http://www.outlook-tips.net Diane Poremsky

    Every test I made showed the pst shrunk, although sometimes by very little. I don't recommend doing this on close - it can take too long. I prefer to let Outlook compact automatically as it has idle time. Either way, the deleted items will be totally unrecoverable after compacting.