Last reviewed on May 24, 2013   —  10 Comments

It’s possible to configure Outlook to automatically compact the pst every time you close Outlook. I don’t recommend doing it (or emptying the deleted folder on exit) as it can lengthen the time it takes Outlook to shutdown and if Outlook is forced to close during the compaction process the data file could become corrupt.

However, this can be useful to users who deal with sensitive data and need to ensure messages can’t be recovered as compacting removes all traces of deleted messages, making it impossible to recover the mail.

Understanding Deletion and Compaction

After you delete messages and other Outlook items then empty the Deleted Item folder, the deleted items are removed from the index so Outlook doesn’t display them but they are left in the data file. The space used by these deleted messages is often referred to as “white space”. Until Outlook recovers this space by compacting the data file, it may be possible to recover deleted messages using recovery software.

Outlook will automatically compact the data file when the “white space” reaches 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 finish compacting the pst file. (If you leave Outlook open when the computer is running it will have more idle time to compact the data file.)

Compact data file dialogIf 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.


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

Press Windows key + R and type regedit in the Run dialog then press Enter to open the registry editor.

  1. Browse to the appropriate key for your version of Outlook.
  2. If the PST subkey does not exist, create it.
  3. Right click on PST key and choose New, DWORD.
  4. Type (or paste) PSTNullFreeOnClose as the Name.
  5. Double click on it and enter 1 as the Value.

For Outlook 2010:


Outlook 2007:

Outlook 2003:

Outlook 2002:

Outlook 2000:

DWORD: PSTNullFreeOnClose
Value Data: 1 = compact on close, 0 = don’t compact

PSTNullFreeOnClose registry key

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.

This key compacts 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.

Doit It For Me

If you don’t want to edit the registry, we have reg files you can use.

Outlook 2010Outlook 2007Outlook 2003


  1. Costen says

    This RegKey PSTNullFreeOnClose (set to 1) does not seem to work for OST (tested with Outlook 2010). Outlook seems to take more time closing (I see the icon in the status bar for far longer time, but no file size change). A manual compress works. Can anybody confirm that they've used PSTNullFreeOnClose successfully to compress the OST automatically when Outlook closes? Thank you! And, thank you Ms. Poremsky for your MS Office articles.

  2. Dan Stevenson says

    Also tested this with Outlook 2010 connected to Exchange online accounts on two workstations so far and it did not work on either. Outlook takes longer to close but the .ost files never get smaller. Ran manual compact on both workstations and the difference in size of the .ost files afterwords was dramatic. Over 70% reduction in size. I wish there was a way to automatically compact .ost files in Outlook 2010 since we have a lot of workstations that I will have to manually compact the files.

    • Diane PoremskyDiane Poremsky says

      They usually recommend deleting and rebuilding the ost instead of trying to repair it - that would work for compact too. It's not bad if the ost is fairly small as it will sync fast. But it can cause network issues if the ost is large.

  3. Dan Stevenson says


    Thanks for your reply. In our case the .ost's are not corrupted, just very large because our employees like to save a lot of mail. I was hoping to find a way to have Outlook automatically compact on close because the built in background compaction does not seem to be working on any of the workstations I have checked so far. I am guessing it is because our workstations are almost never idle long enough for the background process to start.

    • Diane PoremskyDiane Poremsky says

      Yeah, it is because they aren't idle. If they use active screensavers, have them switch to one that is static. When they take a break, leave outlook open and lock the computer, don't sign off and on all day long.

Leave a Reply

Please post long or more complicated questions at OutlookForums by

If the Post Comment button disappears, press your Tab key.