delete - How is free space reclaimed when files are deleted in Windows?

06
2014-04
  • Bart Arondson

    Whenever I delete a large set of files (multiple GB's) I noticed that this doesn't free space as much as I would expect. My expectation is that if I delete a certain amount of data my free space will go up with the same amount.

    However, if I delete 5GB of files, empty the trash and look at the free space on my hard disk, it hasn't gone up with 5GB. This happens both on Windows XP and on Windows 7.

    So what happens with the space that the deleted files were taking in? Why is there no one-to-one relation between the amount of data deleted and the amount of free space reclaimed?

    I found similar questions for Mac and Linux, but not for Windows. I use the Windows Explorer for determination of the file sizes and free space.

  • Answers
  • lightstep

    You can try deleting files directly without moving it to Recycled Bin first. To do this press SHIFT and DEL in Windows Explorer.

  • Tonny

    There are a couple of things to consider here.

    1. Files may be counted twice or more due to hardlinks/symlinks
    2. If "System Restore" is enabled Windows may retain a backup-copy in a hidden location.
    3. Files can be allocated "sparse" which means that unused blocks within the file are not really allocated on-disk. The size shows as the "total" size of the file, but when deleted only the used parts are freed, so there is less gain than expected.
    4. Files can be compressed, so the actual space they take (and which is freed) is substantially less than the reported size.
    5. The MFT (which is an area on disk where NTFS keeps its internal administration) can grow and/or get fragmented which, under some conditions, can mean it grows when you delete files. (Should not make a huge difference though.)
    6. If you delete a file which is still in-use by a program, it can be that the file appears to be deleted, but it will not be really freed until the program releases/closes the file.
    7. Last but not least: In some cases file-system corruption may cause an incorrect reporting of the free space. A "Chkdsk /f" or a "Check & Repair" via the disk-properties gui should sort that out.

  • Related Question

    performance - Reclaiming disk space on Windows
  • nik

    A lot of disk space is taken up by a default Windows installation in various temperory and backup data that may never get cleaned up on its own. Eventually you realize that the large multi hundred gigabyte drive you installed on, is actually running out of space.

    What are your favorite configuration tweaks and routine activities
    on a standard Windows Installation to keep it tidy and clean from a disk utilization standpoint?

    There are probably,

    • many things on the border of being safe
    • some very specific to the flavor of Windows (XP/Vista/7?)
    • and, some that are specific to commonly used applications (Symantec?)

    Please flag your answer with such cautions, information to indicate special conditions and warnings to your best knowledge.

    I'll add my points as an answer.

    Update after a long time.
    Unfortunately, this question has been generalised to that for finding unused-and-large files left on the system by the user themselves. It was not meant to be addressing that space. It was meant to focus on stray things that take up space as a side effect of WindowsTM behaviour or that of applications made for it.
    With the exception of a couple of answers, most are biased towards tools to help people find their own mess --
    I was more interested in finding other-people's-mess.
    Well, I am going to mark my own answer as accepted and leave it at that.
    Those who want that data, will find it here and
    others upvoting tools that help find misused space will show the rest what they want.


  • Related Answers
  • slhck

    WinDirStat

    I like WinDirStat, a free (open source) tool that scans the file system and visually presents statistics about your files. You can use this to determine which files are the largest, where is everything located, etc.

    enter image description here

    From the site:

    WinDirStat reads the whole directory tree once and then presents it in three useful views:

    • The directory list, which resembles the tree view of the Windows Explorer but is sorted by file/subtree size,
    • The treemap, which shows the whole contents of the directory tree straight away,
    • The extension list, which serves as a legend and shows statistics about the file types.
  • slhck

    System Restore Points

    A Windows system creates System Restore points and the default configuration allows a lot of space to be reserved for these restore points. When you know that the system is not going to need 'uninstalls' (meaning, everything you recently installed is working fine) you can delete all but the most recent restore point.

    This can be done from

    • the "Free up space on your hard disk" option in
      • Control Panel,
        • Performance and Maintenance

    Its quite deep and usually missed out.


    Recycle Bin

    The Recycle Bin usually defaults to 10% of your disk partition (for each partition).
    For a 100GB drive, this becomes 10GB reserved for recycle bin.

    • you can reduce the default to a lower value more useful for your setup
    • you can also choose to configure recycle storage individually for each partition

    I also use this short cut to clean the recycle bin once in a while,

    %windir%\system32\cleanmgr.exe /D
    

    Uninstall Folders

    Deleting Uninstall Folders.
    Already mentioned in another answer here.
    There is a script reference here.

    Tested on Windows XP, Requires WScript and VBScript (which would be with most Windows OS)


    RevoUninstaller

    RevoUninstaller is a good freeware to cleanup stray files left around by application uninstalls. It does a pretty neat scan for files hanging around from a rough uninstall.
    I also like CCleaner mentioned in another answer here.

  • slhck

    CCleaner

    CCleaner is good, in the Windows options at the bottom you can clear up hotfix uninstallers, and other Windows stuff.

    enter image description here

    CCleaner is the number-one tool for cleaning your Windows PC. It protects your privacy online and makes your computer faster and more secure. Easy to use and a small, fast download.

  • slhck

    SpaceMonger

    SpaceMonger is a handy utility for figuring out which files / directories are eating up your disk space. It produces a nice interactive graphical map where you can zoom in and out and delete things you don't need at your discretion.

    enter image description here

    Also Nlite and Vlite are useful for building stripped-down installation media for Windows XP and Vista respectively. You can leave out all the extras that you don't use so that your initial install footprint is smaller.

  • ultrasawblade

    To actually address @nik's question, the biggest consumers of diskspace as far as Windows itself (apart from components which can be removed from "Programs and Features" or "Add/Remove Programs") seems to be the driver.cab file and the WinSxS directory.

    I don't know of a tool to "clean" driver.cab. There's many utilities to remove unwanted drivers on a system but to this day I don't know of any I would trust. I do know that nLite on Windows XP (vLite for Vista and later - never tried it) allows you to remove drivers from a created installation disc, and I believe it rebuilds that file (I could be wrong).

    The WinSxS directory gets into .dll versioning stuff and I don't have the courage to mess with that. I remember trying to stuff Vista in a 20GB partition when it first came out and that directory took 6GB all by itself. This was AFTER a clean install.

  • arathorn

    I don't know if these are still present in Vista/7, but in XP, the $NtUninstall**$ folders in your Windows directory can take up quite a bit of space and can be safely deleted (assuming you don't plan on ever needing to uninstall any Windows Updates).

  • Factor Mystic
    • compcln.exe from an elevated command prompt. Makes service packs (Vista SP1+2) permanent but clears some of the backup files.

    • vsp1cln.exe, the same thing but for Vista SP1

  • oKtosiTe

    RidNacs is an easy to use and fast disk space usage analyzer. It scans your local drives, network drives or single directories and displays the results of the analysis in a tree view with a percentage bar.

    This gives the user a quick and easy way to identify the largest directories and it's very useful for cleaning up the disk. The result of the scan can be exported in different formats (XML, HTML, CSV, TXT), so it could be printed or compared with future scans.

    Besides all these benefits RidNacs has an outstanding scan performance and it scores with a small memory footprint

    alt text

  • JCCyC

    Another thing you can delete merrily are subdirectories of C:\WINDOWS with names that begin and end with '$' and have the word "uninstall" in their names. These are backup system files from installations of service packs and OS updates. You'll see they are listed in blue; that means they're compressed. TYpically, you're never going to revert such updates.

    These directories do NOT get erased by the Disk Cleanup tool in XP. I'm not certain about Vista or 7.

  • nik

    SpaceSniffer is a newer tool on the lines of SpaceMonger and WinDirState noted in older answers.
    As of Nov/2012 SpaceSniffer is very mature (also see notes from last year in this other answer)

    enter image description here
    While my question was not really targeted at locating how the user may have used up system disk space,
    I can see that this is a useful aspect of detecting wasted space too.

    From their webpage,

    SpaceSniffer is a freeWare (donations are welcome) and portable tool application that lets you understand how folders and files are structured on your disks. By using a Treemap visualization layout, you have immediate perception of where big folders and files are placed on your devices. Treemap concept was invented by Prof. Ben Shneiderman, who kindly permitted the use of his concept into this tool.

    1. Size of the elements indicates relative size of disk space utilized
    2. Clicking on an element brings out more detail
    3. Double-clicking on an element zooms into that area
    4. Allows filtered searches (say by file extension)
    5. Tagged view with 4 colours that you can designate and then filter the view by tag
    6. Filter by file size or date...
    7. Generate a report with the export module

    IMO, SpaceSniffer is the good blend of WinDirState (which uses too many colour tones and SpaceMonger which is quite old now).

  • ST3

    You can run dism /online /cleanup-image /spsuperseded /hidesp in console, it will clean up service packs backup files.

  • Babu

    Vista (and, from what I've read, XP) does not always delete files when you empty the recycle bin. Sometimes they're stored in a $RECYCLE.BIN folder on your C drive. When I begin to get a little short on space, I delete the entire folder, which gets recreated (minus all of the files) automatically. To delete the folder, you should be in an elevated Explorer window.

    I haven't found a good answer for why the files are there (mainly because I don't care enough to figure it out), but I get the idea that they're kept for restore points. If you feel like you're likely to do a system restore, I'd make a full backup of the drive first.