13

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: Size disparity in Finder

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)?

2 Answers 2

11

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.

0
1

There are other explanation for this file size disparity as well! For example:

screenshot of macOS finder showing a 1.23GB file taking up 2.6MB of space

That's a 1.23GB file taking up 2.6MB on disk, which is clearly too much of a disparity for mere compression. My screenshot is of a spare file representing a partial cache of a file accessible from a networked file system (rclone mount). Essentially it's a virtual file that while appearing to be 1.23GB of space only actually contains 2.6MB of data. There are many other situations where a file's size and its on disk size might dramatically differ: https://apple.stackexchange.com/a/418562/37817

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .