Software & OS

Why Do I Have 140 GB of Temporary Files? (Windows 11)

If you are asking why you have 140 GB of temporary files, the usual reason is that a few large items are counted under one heading: leftovers from Windows updates, a previous Windows installation, and scratch data that programs never cleaned up. Open Start, Settings, System, Storage, Temporary files to see the exact list, then tick only the items you understand and select Remove files.

The number in Settings is a total, not a single folder. The first job is to break it into parts, because the right action for a 5 GB scratch folder is different from the right action for a 40 GB leftover Windows copy. The steps below follow Microsoft's documentation and only use read-only commands to look before you delete anything.

Look at the Temporary files list first

In Windows 11, go to Start > Settings > System > Storage and open Temporary files. You can also reach it through Cleanup recommendations, which Microsoft describes as the place to identify and clean up temporary files and system files. Windows lists each category with the space it would free. Nothing is removed until you tick items and select the button for that section.

The category names and layout change between Windows versions and updates, and Microsoft's pages do not list every category you may see. Trust the names on your own screen. What matters is which line is largest. If one line holds most of the 140 GB, you have found the cause, and the sections below explain the common ones.

Why the total can be so large

These are the sources that Microsoft's own documentation names. Which of them applies to you depends on your machine.

SourceWhat it isCan you delete it?
Previous Windows installation(s)The old Windows version kept after an upgrade so you can roll back (the Windows.old folder)Yes, but it cannot be undone and you lose the rollback
Old Windows Update filesOutdated system files, such as superseded components kept in the component storeYes, through the supported cleanup tools only
Program Temp foldersScratch data that programs store in a Temp folder and usually delete before they quitYes, safely if not modified in the last week
Temporary setup filesFiles left by a setup program that is no longer runningYes, for a finished install
Recycle BinFiles you deleted but did not remove permanentlyYes, but you can no longer restore them

Two of these deserve a closer look because they are the most likely to reach tens of gigabytes.

The previous Windows installation

After a major upgrade, Windows keeps the older version so you can go back. Microsoft's guidance is to open Temporary files, check Previous Windows Installation(s) and select Remove files. It warns that this cannot be undone. Once it is gone, you cannot return to the older version. If you upgraded recently and have not yet decided that the new version works for you, leave it ticked off. If the machine has been stable for weeks, this is often the safest big win.

Leftover Windows Update files

Windows keeps earlier versions of updated system components for a while so updates can be rolled back. Microsoft says the automatic cleanup task waits at least 30 days after an updated component is installed before it uninstalls the previous versions. Microsoft also describes component cleanup as the way old Windows Update files get removed, and strongly recommends not disabling it, since disabling it lets unnecessary files accumulate.

These files live in the WinSxS folder, which is one reason that folder looks huge in a size listing. Do not delete anything inside it by hand. Microsoft warns that deleting files from WinSxS, or the whole folder, may severely damage your system so that your PC might not boot and it becomes impossible to update.

Measure your own Temp folder

Your account's Temp folder is the one most programs write to. This read-only PowerShell command totals its size in gigabytes. It does not delete anything:

$bytes = (Get-ChildItem -LiteralPath $env:TEMP -Recurse -File -Force -ErrorAction SilentlyContinue |
    Measure-Object -Property Length -Sum).Sum
[math]::Round($bytes / 1GB, 2)

Example output (your number will differ):

3.82

-ErrorAction SilentlyContinue hides "access denied" errors, so files that are locked or that you cannot open are skipped and not counted. If this prints a few gigabytes while Settings reports 140 GB, your own Temp folder is not the main cause. Look at the Windows-owned items in the table instead.

If your Temp folder is the big one, find which files are largest before deleting anything:

Get-ChildItem -LiteralPath $env:TEMP -Recurse -File -Force -ErrorAction SilentlyContinue |
    Sort-Object Length -Descending |
    Select-Object -First 10 FullName, @{Name='SizeGB'; Expression={[math]::Round($_.Length / 1GB, 2)}}

A single multi-gigabyte file with the name of a program in its path usually means that program did not clean up after a crash or a failed install. Close the program first, since files in use cannot be removed and you should not try to force it. For a wider search beyond Temp, the large-file search guide covers whole-drive scans.

Clear temporary files safely

  1. Close your open programs, so their scratch files are not in use.
  2. Open Start > Settings > System > Storage > Temporary files.
  3. Read each category. Tick the ones you understand. Leave Previous Windows Installation(s) unticked unless you are sure you will not roll back.
  4. Select Remove files.
  5. Empty the Recycle Bin. Microsoft's page says that deleted files are only completely removed from the device once you do, so the space does not come back until then.

Microsoft's rule of thumb from the cleanmgr reference is that you can safely delete temporary files that have not been modified within the last week. A file modified an hour ago may belong to a program that is running right now. If Windows says some files could not be removed, that is the likely reason, and a restart followed by a second attempt often clears them.

Shrink the Windows Update leftovers with DISM

If Settings does not remove the update leftovers, or you want the effect immediately, run this from an elevated Command Prompt or PowerShell (right-click Start, then choose the Terminal (Admin) option):

Dism.exe /online /Cleanup-Image /StartComponentCleanup

Microsoft says this gives results similar to the scheduled StartComponentCleanup task, except that previous versions of updated components are deleted immediately, with no 30 day grace period and no 1 hour timeout. There is a stronger switch, /ResetBase, which removes all superseded versions of every component. Microsoft's warning is that after it completes, all existing update packages cannot be uninstalled, although uninstalling future updates is not blocked. Unless you have a clear reason, use the plain command above and skip /ResetBase.

Stop it from building up again

Storage Sense can take over the routine cleanup. Go to Start > Settings > System > Storage and turn Storage Sense on. Microsoft documents several limits you should know about:

  • It acts only on the Windows system drive, not on other drives.
  • It cannot run unless you are signed in and online for more than 10 minutes.
  • Its settings apply only to the signed-in user.
  • It is off by default, although Windows may switch it on to deal with temporary files when disk space runs low, and then notify you.

Avoid its Downloads rule unless you mean it. The option to delete files in your Downloads folder that have not been opened for a set time will remove an installer or document you downloaded months ago and meant to keep.

For a longer walk through every Disk Cleanup category and the cleanmgr /sageset and /sagerun options, see the Disk Cleanup guide. To check whether the rest of the drive is full of your own files rather than temporary ones, use the guide to seeing what is taking up storage.

If the total is still huge after cleaning

Check three things in order. First, did you empty the Recycle Bin? The space only returns after that. Second, run the Temp folder measurement again. If it grows by gigabytes in a day or two, one program is the cause, and the largest-files command above will show which. Third, check whether Settings counted the same files twice in your mind: the Storage page can show Temporary files as one slice of the bar, while the Windows folder and your user folders are separate slices.

If the drive is still nearly full with nothing large in Temporary files, the space is in your own files or installed apps. Microsoft's advice is to check Videos, Music, Pictures and Downloads, which often hold the largest files, and to consider moving rarely used files to external storage or turning on OneDrive Files On-Demand so that files stay as placeholders instead of full local copies.

Frequently asked questions

Is it safe to delete 140 GB of temporary files?
Mostly yes, but read the list before you clear it. Microsoft says you can safely delete temporary files that have not been modified within the last week. The exception is the previous Windows installation (Windows.old): deleting it cannot be undone and you lose the ability to roll back to the older version.
Why do temporary files keep coming back after I clean them?
Programs and Windows Update create them continuously. A large total that returns within days usually means one program is writing scratch data to its Temp folder and not removing it, or that updates keep staging files. Measure the Temp folder before and after a few days of use to see which one is growing.
Can I delete the WinSxS folder to free space?
No. Microsoft warns that deleting files from WinSxS or the whole folder may severely damage the system so that the PC might not boot and cannot be updated. To shrink it, use the supported commands, such as Dism.exe /online /Cleanup-Image /StartComponentCleanup from an elevated prompt.
Will Storage Sense stop temporary files from piling up?
It helps. Storage Sense removes unnecessary temporary files automatically, but it only acts on the Windows system drive, only runs when you are signed in and online for more than 10 minutes, and is off by default. Windows may turn it on by itself when disk space runs low.

Sources