File Size and File Size on Disk

This is a discussion on File Size and File Size on Disk within the A Brief History of Cprogramming.com forums, part of the Community Boards category; I was looking through some files to try and free up some HD space, and there are two different file ...

  1. #1
    l'Anziano DavidP's Avatar
    Join Date
    Aug 2001
    Location
    Plano, Texas, United States
    Posts
    2,738

    File Size and File Size on Disk

    I was looking through some files to try and free up some HD space, and there are two different file sizes on each file. One is called simply "Size" and the other is called "Size on Disk". The "Size on Disk" is always just slightly higher, depending on how big the "Size" is.

    Ex: Size = 10 kb
    Size on disk is probably around 13 kb

    size = 123 MB
    size on disk is probably around 135 MB

    what the heck is the difference? why are they different?
    My Website

    "Circular logic is good because it is."

  2. #2
    Linguistic Engineer... doubleanti's Avatar
    Join Date
    Aug 2001
    Location
    CA
    Posts
    2,459
    it's due to cluster size... on FAT 32 drives, you can assign 4.2 billion [2 ^ 32] files/folders... it ends up being 4 K on smaller gig drives, and 16 K on bigger... the old FAT 16 system only allowed for 65536 files, which is why the cluster size on an x gig drive would be really large [16k] and would waste a lot of space... oh, and on clusters, even if the file is 1 byte, it takes up the entire cluster... [it has to do with the file system... and it's addressibility setup...] switching from FAT16 to FAT32 really helped us out, saving hundreds of megs since Windows has tons of tiny files... which might be only 1 K but take up 16!...

    so, the actual size is that of the files, and the size on disk is that of the clusters that the files occupy... truncated up... which is why it is larger...

    a practical application of this would be to ensure that you have larger source code files, so you aren't wasting those precious kilobytes!
    hasafraggin shizigishin oppashigger...

  3. #3
    l'Anziano DavidP's Avatar
    Join Date
    Aug 2001
    Location
    Plano, Texas, United States
    Posts
    2,738
    what about NTFS? the one that XP uses? does it address this in any way?
    My Website

    "Circular logic is good because it is."

  4. #4
    Registered User
    Join Date
    Sep 2001
    Posts
    412
    This isn't really much of a problem. Clusters are almost a necessity if you plan to allow files to be stored noncontiguously (fragmented). Every file system uses some technique of clustering, though the cluster size may vary. Too large of clusters means you waste, on average, more space per file, and too small of clusters means you waste too much space with headers and the like. Cluster sizes are chosen intelligently to try to minimize both problems at once, and the specific balances struck are reasonably good.

  5. #5
    Linguistic Engineer... doubleanti's Avatar
    Join Date
    Aug 2001
    Location
    CA
    Posts
    2,459
    speaking of which... i was thinking, well, why don't harddrives just randomly place the files instead of sequentially... that way you'd have a better opportunity of reducing fragmentation at the cost of access time...which could be remedied by using more physical discs... plus using a 4k size seems impractical if most writes would be larger then that... or does FAT32 allow extra buffer for expansion space? this is really interesting... anyone have any lynks to specifications? thanks alot...
    hasafraggin shizigishin oppashigger...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. File transfer- the file sometimes not full transferred
    By shu_fei86 in forum C# Programming
    Replies: 13
    Last Post: 03-13-2009, 12:44 PM
  2. Trouble with DMA Segmentation Faults
    By firestorm717 in forum C Programming
    Replies: 2
    Last Post: 05-07-2006, 09:20 PM
  3. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  4. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 09:54 AM
  5. System
    By drdroid in forum C++ Programming
    Replies: 3
    Last Post: 06-28-2002, 10:12 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21