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

3

1

Whenever I delete a large set of files (multiple GB) 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.

Saaru Lindestøkke

Posted 2013-11-24T23:42:11.033

Reputation: 1 275

Are we talking about 2 or 3%? Or are we talking about gigabytes? – David Schwartz – 2013-11-25T01:12:52.383

I just threw out 10.5 GB of data. After emptying the bin I reclaimed 4.5 GB free space. This is not consistent though and varies a lot. – Saaru Lindestøkke – 2013-11-25T01:34:50.420

2The data isn't hardlinked/symlinked in any form, is it? Other than this, only if you have a process gobbling any free space you have or you just have very little space and the paging file (virtual memory) is expanding to the free size you just left. – Doktoro Reichard – 2013-11-25T02:24:57.333

1You need to specify EXACTLY how you determine both the size of the files you deleted, and the alleged free space. The pronouncements of Windows Explorer, for instance, are notoriously unreliable, as it frequently double counts linked files. Certain NTFS filesystem features will naturally result in fewer bytes being "freed" than were contained in a deleted file. For a reliable reckoning of filesystem freespace, use something that consults the NTFS Allocated Cluster $Bitmap metafile. – kreemoweet – 2013-11-25T04:34:27.297

The files are not symlinked. They are data files created by a simulation program. I use Windows Explorer to check sizes, so that might be the reason for the incorrect behaviour. Now I'm curious on why the Explorer does not show free space reliably, but that is content for a new question. – Saaru Lindestøkke – 2013-11-25T13:25:21.343

You may be suffering from MFT fragmentation. Try the answers to the question: http://superuser.com/questions/316003/how-do-you-defragment-the-mft-on-an-ntfs-disk

– nitro2k01 – 2014-01-22T11:46:30.010

Answers

3

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.

Tonny

Posted 2013-11-24T23:42:11.033

Reputation: 19 919

Although a useful answer, it doesn't answer the question. – Nic Szerman – 2018-07-17T14:40:09.220