How accurate are the Finder’s folder and volume sizes?

As any good accountant will tell you, the numbers have to add up. Having demonstrated the Finder’s inaccuracy in reporting the size of files with substantial extended attributes, because of a bug in macOS, this article examines how that might propagate up to affect sizes given for folders and volumes. If the size of a file is underestimated, does that mean that volume free space is overestimated?

Method

A Zip archive containing three test files was copied to a freshly formatted APFS volume on an external SSD, on a Mac Studio M1 Max running Sonoma 14.4.1. Measurements were taken from Disk Utility’s Info, the Finder’s Get Info dialog, and my free app Precize, following unarchiving of the test files. Precize gives the following measurements:

size in bytes using URL Resource Keys fileSizeKey and totalFileSizeKey,
size in bytes from the size key in the file attribute dictionary,
total size of all extended attributes by iterating through them and totalling size returned by getxattr() on each one

As previously demonstrated, URL totalFileSizeKey doesn’t in fact return the total of data and all extended attributes, but gives a number greater than or equal to fileSizeKey and less than or equal to true total file size including all extended attributes.

Results

Total sizes for the three test files were underreported by the Finder as previously. The first file, actual total size 344,459 bytes, was given as 263,195 bytes in Get Info, and the other two, each with an actual total size of 360,492 bytes, were given as 391 bytes in Get Info. Thus the total file size, actually 1,065,443 bytes, was reported by Get Info as 263,977 bytes, a discrepancy totalling 801,466 bytes.

Calculating the total size occupied on the volume is more complicated, as there were (as expected) three hidden folders, .fseventsd, .Spotlight-V100 and .TemporaryItems. According to Get Info, the total size of those was 1,065,365 bytes, almost all of which was in the Spotlight indexes. The estimated grand total of ‘actual’ file sizes on that volume came to 2,659,521 bytes. The total given by Get Info for that volume, and that provided by Disk Utility, was slightly less than that, at 2,531,328 bytes.

Interpretation

Sizes given by the Finder’s Get Info dialog remain in error for individual files and folders, with the latter being totals of erroneous values for the files within them. However, volume totals aren’t obtained from the sum of the sizes of items in the volume, but tally with the values given in Disk Utility and appear to be derived from APFS. Those include all file data, and extended attributes. According to the Finder’s figures, 673,639 bytes were unaccounted for in the size of files on the volume, and presumed to be within the file system metadata.

Extended attribute storage

In APFS, a file’s extended attributes aren’t stored with that file’s data, but as shown in the diagram below, they’re kept separately.

For smaller extended attributes up to 3,804 bytes, their data is stored with the xattr in the file system metadata. Larger extended attributes are stored as data streams, with separate records, but still separately from the file data.

One possible explanation for the erroneous totalFileSizeKey values given is that they might exclude those larger extended attributes stored as data streams. Unfortunately, the evidence here demonstrates that can’t be a valid excuse: one of the three test files here has a data size of 183,136 bytes and a total size of extended attributes of 161,334 bytes, in two large xattrs and several smaller than 3,804 bytes. The Finder’s Get Info total does include one of those large xattrs to arrive at its incorrect total size of 263,195 bytes for the file, but excludes the other large xattr and all the smaller ones.

Conclusions

Figures given for file and folder size in the Finder’s Get Info dialog may not represent the size of the data alone, nor the sum of data and extended attributes, but a value somewhere in between those.
Figures given for the size used on a volume in Get Info and in Disk Utility appear to be accurate, and do include the total of all extended attributes and data, as they appear to be derived independently of erroneous totalFileSizeKey values.
There is thus likely to be a substantial gap between the Finder’s figures for a volume, and the total size of the files and folders in that volume, which represents the extended attributes omitted when calculating file and folder sizes.
There is no evidence that errors in reporting file and folder sizes in the Finder affect estimates of free space in a volume.