Macos – Why are Mac OS X alias files so large

aliasfilesystemshfs+macos

On Mac OS X, I have two aliases in my Applications folder, each points to another folder. They are 1 MB each. Why so large?

I've found other sources on the Internet to say that yes, alias files can be large, but no explanation why. Even if they store a lot of redundant information to find the target file in case it moves, I can't imagine why an entire megabyte would be needed.

Best Answer

First of all, I wonder if the 1 MB is correct: true, Finder's Show Info tells you this, but in Terminal the file sizes are always just half of that. Odd.

The size is due to embedded icons. Note that an alias to an application (more precisely: an application bundle) might be much smaller than an alias to a plain folder. Hence, I guess plain folders use a higher definition icon than, for example, iTunes does. And indeed, if you change the icon of the source, the icon of the alias is not changed.

In Terminal you'll see:

ls -l@

drwxr-xr-x   2 arjan     staff       68 Nov 14 09:20 MyFolder
-rw-r--r--@  1 arjan     staff   519012 Nov 14 09:20 MyFolder alias
    com.apple.FinderInfo         32 
    com.apple.ResourceFork   518659 

drwxr-xr-x   2 arjan     staff       68 Nov 14 09:26 MyOtherFolder
-rw-r--r--@  1 arjan     staff   519040 Nov 14 09:26 MyOtherFolder alias
    com.apple.FinderInfo         32 
    com.apple.ResourceFork   518679 

So: 4 bytes more in the "Resource Fork" for each letter in the file name, and on the file system things are padded a bit. That same Resource Fork also includes the icons. If you have the Apple Developer Tools installed:

DeRez "MyFolder alias" > MyFolderAlias.txt

That text file then shows you more than 32,000 lines of text that represents the icon.

(See also Ars Technica about HFS+. Without the Developer Tools, your can use xattr -l to kind of see what's in those extended attributes.)

Related Question