Mac OS X Finder: Substantial disparity between "Size" and "on disk" values for file
On Mac OS X (I'm using 10.8/Mountain Lion), you can inspect files in the Finder via Option-Click -> "Get Info". Doing so opens a panel with all sorts of information. In the top right corner, you can see the file size in MB. Next to "Size" (filed unter "General"), you get more detailed information: The size in bytes, as well as another size in MB on disk.
I noticed that some files have a substantial difference between their size in bytes/the value in the top right corner, and the on disk value. One example is the Clang binary:
Can anyone explain why there's such a huge difference (26.3MB vs. 10.9MB)? Are parts of the file shared (I have installed the Xcode command line tools, so the file exists in multiple locations)?
HFS+ compression!
The "Size" value represents the uncompressed size of the data in the file. The "on disk" value is how much storage is really needed for the compressed data. The Mac OS X Hints site provides background on how this compression is implemented, and provides a link to the helpful hfsdebug
tool that can be used to get information on compressed files.