Nehmo said:
When you look at the properties of a file in Windows XP Explorer, it
lists two sizes: Size, and Size on disk. The Size on disk is larger by
a fraction. What's the explanation of this?
In Corel Paint Shop Pro X, when I look at image information, there's
two sizes there too. I see On disk, and In RAM. The In RAM amount is
ten times larger than the On disk amount for one jpeg. What's the
explanation of this?
On a hard disk each file is stored in a number of clusters. Almost
always the last cluster is not completely filled, and the empty space
cannot be used by another file. The size on disk is the total size of
all the clusters used to store the file.
For instance, on my computer the F: drive is an 80GB drive that is
formatted in FAT32. The cluster size is 32KB. One particular file there
has a size of 103KB and a size on disk of 128KB, which is the total size
of the four 32KB clusters that the file occupies.
This can become very wasteful of disk space if you have a large cluster
size and many small files. For instance, I have a folder that contains
522 small data files that are all around 2KB (or a little less). In the
properties for that folder, the size is listed as 960KB. But the size on
disk is 16.3MB (17,104,896 bytes). This because each 2KB file occupies a
single 32KB cluster and 522 times 32KB (32,768 bytes) gives 17,104,896
bytes.
This is one of the advantages of the NTFS file system. It usually uses a
4KB cluster size, which means that folder with 522 small files only
takes up 2.03MB (522 x 4K) when it is stored on an NTFS formatted drive.
The other solution is to store the folder as a single zip file... then
with compression, and only one partly filled cluster for the single
file, it takes up only 633KB or 640KB on disk.