Why are Mac OS X alias files so large?

7

1

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.

benzado

Posted 2010-11-14T07:06:06.160

Reputation: 521

Answers

3

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

Arjan

Posted 2010-11-14T07:06:06.160

Reputation: 29 084

ls -lh will be more human friendly when you want to know the size. – Albert – 2015-04-06T23:56:16.360

I'm pretty sure the Get Info file size is correct; it's the total of data and resource fork. I guess the icon data is stored in both forks. – benzado – 2010-11-14T09:47:03.917

@benzado, after reading Ars Technica, I thought Resource Forks were now only embedded in the extended attributes (which, if I understand correctly, are actually in the Data Fork?) – Arjan – 2010-11-14T09:49:43.383

Data fork, resource fork, and extended attributes are all separate. – benzado – 2010-11-14T09:51:30.463

1For "My Folder alias" I get "1 MB on disk (1,037,671 bytes)", while 519,012 + 32 + 518,659 = 1,037,703. Hmmm. 519,012 + 518,659 = 1,037, 671 indeed. – Arjan – 2010-11-14T09:54:39.740

I need to read again. I really thought Resource Forks were history (but got reintroduced within the extended attributes)! Now I'm confused while I was just trying to help, @benzado ;-) – Arjan – 2010-11-14T09:56:16.993

1Although resource forks usually have a standard format (defined by the Mac OS Resource Manager), an app can use the resource fork to store information in any format it chooses. So the OS can't use resource fork to store extended attributes, since it couldn't guarantee they wouldn't clobber some app-specific data. Glad we can help each other! – benzado – 2010-11-14T11:15:07.407

@benzado, after xattr -d com.apple.ResourceFork "MyFolder alias": output of ls -l@ no longer shows it (and ls -l@ "MyFolder alias/rsrc" reports zero); ls -l still shows 519012; Get Info reports "520 KB on disk (519,012 bytes)"; restarting Finder shows the default icon, also when the source had a custom icon. So, some extended attributes (like Finder.Info) can be in the data fork, while others can be in the resource fork? Okay. Setting a DIFFERENT custom icon gets me the extended attribute again, with a DIFFERENT size, but the 519012 size does NOT change. What's in there? ;-) – Arjan – 2010-11-14T12:21:32.303

(And other aliases have a different size for that data fork...) – Arjan – 2010-11-14T12:21:53.503

0

In High Sierra, the following works: just select the alias and run Finder command "Show Original" (command-R). This trims the alias size down to a minimum. This brought an alias that was previously 24 Mb down to 8 Kb.

Marc

Posted 2010-11-14T07:06:06.160

Reputation: 1