Reclaiming Disk Space in Windows 10

  Subscribe
6/19/2019 - Marco von Ballmoos

About five years ago, I wrote Who's using up my entire SSD?. Much of the advice given in that article is still applicable, but I have an update for more modern applications and packages.

Overview

I use the following tactics to manage free space on my Windows machine:

  • Use the "Disk Cleanup" tool included with Windows
  • Use the "PatchCleaner" tool to remove unneeded packages from the Windows/Installer folder
  • Use "TreeSizeFree" to find out where else you're losing space (usually AppData)
  • Move settings/caches to another drive (e.g. "ReSharper")
  • Clear "NuGet" caches
  • Uninstall other unused software (especially Windows and .NET SDKs )

Disk Cleanup

This tool is available from the Windows Menu and works pretty well for basic cleanup.

  • Use "Clean up System Files" to clean not only user files, but also system files
  • Use it after installing larger Windows Updates because it will often offer to clean up multiple gigabytes from the Windows Update cache after such an update
  • For some reason, it rarely manages to empty my recycle bin or temp folder reliably, so check afterwards to see if you still have GBs lying around there

PatchCleaner

The PatchCleaner utility determines which patches in the Windows/Installer folder correspond to installed software. Windows does not clean this up, so it's possible that patches are still lying around that correspond to very old software that has either already been uninstalled or that can no longer be uninstalled using that patch.

The software offers to move the patches to another drive/folder or simply delete them. I've been using the utility for over half a year and have never had a single problem with Windows (i.e. I've never had to restore any of the packages that PatchCleaner removed). At first, I moved the patches, now I just delete them.

TreeSizeFree/AppData

I've been using TreeSizeFree by Jam Software for a long time. It's fast and easy to use. I almost always find that, other than the Windows folder, the largest folder is my user's AppData/Local folder.

In order to avoid UAC in Windows, many applications now install to this user folder by default. This is a good thing, generally, but some applications also keep copies of their installations—and then never delete them. This practice can eat a lot of space for applications that are frequently updated.

On my machine, the main culprits are:

  • JetBrains ReSharper
  • Syntevo SmartGit

These applications have since improved their cleanup practices, but it pays to check whether you've still got installers/caches for older versions.

See the Uninstall section below for how to best remove the old versions.

NuGet

If you're using Package References and more-recent versions of NuGet, then you'll have local caches of packages. While this practice saves a lot of hard-drive space by consolidating caches for all solutions, the default location is in the user's AppData/Local/.nuget folder.

You can either clear everything with the following command:

nuget locals all -clear

or you can change the location with an environment variable NuGetCachePath (see Can the NuGet 3.2 package cache location be changed for more information).

My cache is 2.2GB right now, but I haven't moved it yet.

ReSharper Caches

By default, ReSharper stores its caches in the user's AppData folder. From the ReSharper Options/General/Caches, you can change that location to another drive. That folder is currently 1.6GB on my machine, which is not insubstantial.

Uninstall

Most manuals about saving disk space start with this step. I've assumed that you're a developer who has already checked this list, but it doesn't hurt to mention it.

  • Open "Apps and Features"
  • Sort by size

Here you might see the older versions of ReSharper or SmartGit that I mentioned above. If so, go ahead and remove them using the uninstallers.

If the uninstallers don't work and you still see them using a lot of space in your AppData folder, then do the following:

  • Note the version that you have installed (or just use the latest)
  • Uninstall all versions
  • Clear the local cache/uninstaller folders in your AppData folder manually
  • Reinstall the latest version
  • You should only see a single installation now, in both the "Apps and Features" list as well as the AppData folder.

You can also gape in awe that "Microsoft SQL Server Management Studio" takes a breathtaking 2.8GB. Shake your head ruefully that you unfortunately need it and can't uninstall it. Or maybe you can? If you have JetBrains Rider, then you also have JetBrains DataGrip, which is an excellent SQL Server client.

SDKs

I mention SDKs explicitly because they can take a lot of space and most of them are completely superfluous—a newer version generally completely replaces an older version, even if you're targeting the older version from a solution.

For example, I had five Windows SDKs on my machine, each of which weighed in at ~2.5GB. These SDKs were for targeting versions of Windows that I'd long since upgraded. Several of them seemed only to be useful if I was doing C++ development (which I have occasionally done, but which happens rarely and doesn't target the Windows API very heavily). I was able discard all of these packages without any drawbacks.

Next up were the dozens of .NET Core and Framework SDKs for older—and sometimes exquisitely specific (e.g. .NET Core 1.0.4 rc4 preview 2)—versions, each weighing in at between 350MB and 500MB. I was able to remove all but the most recent versions, .NET Core 2.2 and .NET Framework 4.7.2. I have projects that target .NET Core 2.0 and 2.1 explicitly, and they are unaffected.

Conclusion

Those are most up-to-date tips and tricks I've got for managing hard-drive space. I don't try to optimize my main application installations, like Visual Studio or Office. They seem to spread their data over the Program* folders, but I'm not going to touch those, as long as I've got other places to optimize.

I've been using and upgrading my Windows image heavily for .NET (and other) software development for almost years without re-imaging and currently I've got a total of 161.6GB, divvied up as shown below.

Folder Size Description
Windows 55GB
Users/marco 25.5GB installers, caches, etc.
Users/public 6.5GB Hyper-V/Linux subsystem disk image
Program Files (x86) 23.4GB
Program Files 20.8GB
Files 17.4GB Hibernate file, paging file
ProgramData 9GB

Sign up for our Newsletter