I was having a look at the size of libBLAS.dylib at some location in my Mac and du showed it's file size as 572K while the allocated file size (showed by Finder) was 1.4MB. I've read that the lack of sparse files on HFS+ can cause this discrepancy.

My question is that why would a compiled shared library need to be sparse - after all, it's not like anything is going to be modifying it.

  • Wonder if it could be that du counts files in 512-byte blocks, while the Finder counts them in 4096-byte blocks due to HFS+? – gosmond Feb 25 '13 at 8:49
  • 1
    Then the difference should be 4K at most, not more than 0.8MB – Opt Feb 25 '13 at 9:12
  • 1
    Is your question why there is a difference in the reported size, or why this file needs to be a sparse file? – Gerry Feb 25 '13 at 9:30
  • The former but I'm guessing that's going to involve some explanation of the latter? – Opt Feb 25 '13 at 19:00

Difference is in units they use.

du uses BLOCKSIZE=4096 bytes by default (rounded if Human Readable format option -h i.e. df -h) Finder uses BLOCKSIZE=1000 by default

$du -h /usr/lib/libblas.dylib 
4.0K    /usr/lib/libblas.dylib

and same in Finder.

  • 2
    Can you describe how this explains the "factor 2" difference in size reported by the asker? – nohillside Mar 7 '13 at 8:21
  • df -h and df -k gives same results – Eir Nym Mar 7 '13 at 8:32
  • 1
    I hope they do! But how do you explain the difference to the size reported by Finder? – nohillside Mar 7 '13 at 8:43
  • I've explained how Finder says same as du – Eir Nym Mar 7 '13 at 8:46
  • @EirNym In the answer (if I understand correctly), you state that using du -h should give the same result as the file size in Finder. However, I tried running du -h to get the file size of my home folder and it doesn't match the file size Finder reports. (Finder: 122.13G, du:161G) – Arc676 Oct 3 '14 at 4:56

You must log in to answer this question.

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