Why does the Disk Cleanup tool’s Windows Update Cleanup take so long and consume so much CPU?

Raymond Chen

If you ask the Disk Cleanup tool to clean up Windows Update files, you may find that it takes a long time and consumes a lot of CPU. What the heck is it doing? How hard can deleting files be?

The Windows Update Cleanup option is doing more than just deleting files. It’s basically doing two things.

First, it does the equivalent of dism /Online /Cleanup-Image /StartComponentCleanup. This is a command that goes by the nickname deep clean, and it scavenges the component catalog looking for components that are no longer being referenced. Normally, the system automatically does component scavenging on a schedule maintenance task. The automatic scavenging has a policy of waiting 30 days before removing an unreferenced component, and it also has a self-imposed time limit of one hour. But the special command line above bypasses both the 30-day grace period and the 1-hour timeout. Unreferenced components are removed immediately, and the task will run to completion, even if it takes more than an hour.

(I don’t know if the one hour timeout is actually meaningful in practice. I suspect it’s there just as a backstop in case the scavenging process goes haywire.)

The other thing that the Windows Update Cleanup task does is check with the Wof­Should­Compress­Binaries function to see whether the system would benefit from compression of system files. If so, then it takes the operating system files that aren’t already compressed and compresses them, storing the result in the WofCompressedData alternate data stream, as I described some time ago.

The compression algorithm used by the Windows Overlay Filter is higher quality than a real-time compression algorithm, and it’s designed so that decompression is fast, but compression is expensive. And that’s the cost: You need to spend a lot of CPU time to do the compression, which is why the Windows Update Cleanup is using so much CPU time.

And it’s doing the expensive data compression because it’s trying very hard to free up disk space. Because that’s presumably why you are running the Disk Cleanup tool.

5 comments

Discussion is closed. Login to edit/delete existing comments.

  • Piotr Siódmak 0

    Well dang, I was running the cleanup tool manually because I knew it uses quite some CPU and wanted it to get it over with on my schedule rather than random system schedule. Guess I should stop doing that.

    • cheong00 0

      Well, if you can allocate some time slot that you’ll not be using your machine, it’s good idea to assign these CPU consuming task at that time so it’ll not get into your way when you are using it.

  • Joshua Hudson 0

    We exceeded the hour run on a Server 2008 R2 box. The ability to garbage collect components superceded by hotfixes had finally been backported and the first run took two hours.

  • Jan RingoÅ¡ 0

    Team /ResetBase represents! 🙂

  • James Lin 0

    Does Windows Update Cleanup keep track of uncompressed system binaries that it already tried to use Wof­Should­Compress­Binaries on, or will Windows Update Cleanup keep trying to recompress the same binaries each time it’s run?

Feedback usabilla icon