View Full Version : How big is an alias?

25th February 2010, 09:59 PM
I have just been reorganising some files and created aliases to save space and avoid saving the same information twice. I was amazed to see the size of my aliases shown as 164k, in one case bigger than the original file! I expected them to be of the order of 10k, as after all they're basically just an icon and a link. Is this normal. I remember from my pre OSX days aliases of 2k!

Is the size related to disk size? These are on my external 500GB HDD - I notice the ones on my 100GB drive are only 64k.

25th February 2010, 10:27 PM
I think it depends on how many files are linked with the alias. I went through my alias' and found that the more files the original folder has, the larger the alias.

25th February 2010, 10:39 PM
I don't know what determines it, but I have seen some huge ones of late. Back in the day (Classic MacOS) an alias would be just 286 bytes most of the time. I don't know what's happened to the Alias Manager, but it's nowhere near as good as it used to be, or should be.

I doubt that it's disk related. I've just checked a few here and they vary a lot in size for no apparent reason. Recent aliases of folders are mainly around 1MB for some bizarre reason. Old aliases of files are all under 1KB, recent ones are up to 100 or so KB from what I can see.

25th February 2010, 10:57 PM
I am also curious to know how aliases are made in OS X. I assumed when OS X came in that aliases would be constructed in the same way as symbolic links in UNIX (which would mean the alias would always be a constant, small size). They're obviously not done this way, though, since the two types of files behave quite differently - but it makes me wonder why they made them different.

25th February 2010, 11:26 PM
As far as I know, there are 3 distinct kinds of aliases under OS X. In the old days, every file got an id when it was created, which stayed with it until it was deleted or moved to another volume. The alias stored this number in the resource fork in the 'alis' resource. These were all exactly 286 bytes. Wherever the original files was and whatever it was called, the alias would track it because it knew the id & the id didn't change. The second and third types wer created when OS X came along and I don't know as much about them. They are more like symlinks, but they differ in some ways. They share the characteristic that the old ones didn't have - they break more easily.

This is from the Dev Docs on the Alias Manager:

The exact makeup of an alias record depends on the file system in which the object resides. The Alias Manager takes advantage of persistent object ids, creation dates, file types, creator codes and the like if they are available. By default, an object at the location stored in the alias record will be considered a stronger match than an object with the same file id in a different location. (You can alter this behavior by passing flags to the functions that resolve the alias.)

The Alias Manager supports two types of alias records. The standard alias contains as much information as the Alias Manager can gather from the underlying file system. The minimal alias only stores a subset of the information in a standard alias record. A minimal alias may be used when the object is unlikely to move, the reference is to be short-lived, or space is a critical issue (the exact space savings depends on the underlying file system format.) The standard alias is the preferred format because it is more robust.

OS X still supports old Classic MacOS aliases and obviously understands symlinks too. It seems that the latter are not used because Apple think aliases are better. Symlinks are just a text file with a posix path in it aren't they?

26th February 2010, 12:26 AM
Why is it that the larger the original application the larger the alias? I've created a whole bunch of alias' to use as stacks on the dock. The VLC alias is only 45KB whereas Toast Titanium 10 is 516KB? I am really confused. Can someone please explain this to me in the simplest way? Please.

26th February 2010, 08:23 AM
About this big.

http://img88.imageshack.us/img88/2589/aliaszg2.jpg (http://img88.imageshack.us/i/aliaszg2.jpg/)

I just made one for my (quite small) work itunes library and it was 292kb and an alias for a 1.7mb jpeg was 164k....
seems it does indeed vary depending on the size of file it links to.

26th February 2010, 04:23 PM
I think it's storing the icon (twice), and maybe some metadata. I just created aliases for several of a few different types of files and the aliases they created were all the same. If you dump the contents of one of them the very first line looks something like (this is for TextEdit document) this, followed by general gibberish:

Untitled.rtf(&??t???So?A?ǬP$6F31ECE8-AF01-397B-B28A-387349993190?Untitled??icns??ics#H???????'???????? ?????????????????????

Looks suspiciously like it's keeping a copy of the icon in there, probably because it's taking the icon your file originally had (for many, that is the default icon that's not actually in the file itself), and storing it for future reference. It also seems to be storing the icon twice, for some reason, as I'll explain below.

Take my .rtf example. The original file size was 4KB, but most of that was metadata because there were only 6 characters inside the file itself. It would have been referencing the standard icon from it's location within OS X, keeping it's filesize down. So I created an alias of that file, which weighed in at 98KB. I can't be sure because I can't find the original icon, but I suspect it's keeping a copy in the alias itself. I tried making a larger .rtf just to be sure, and well enough each alias was 98KB (each alias of different .avi files I made all weighed in at 328KB regardless of their size).

Next, I changed the icon of the original file with a random image I had on my desktop. After that the original file weighed in at 172KB. Then I made an alias of that file again, which now weighed in at 344KB, exactly twice the size of the original file. It's storing the icon twice, though there appears to be 4-8KB of unaccounted for data ... maybe it's also storing the metadata twice.

Now look at the 98KB alias, which hasn't changed icon or file size. Now change it's icon to the same as the others and it weighs in at 266KB, 168KB heavier (172 KB minus the 4KB of the original file?). Delete the icon and it reverts to normal and the file size drops. Delete the original icon and it reverts to a standard document icon, but the file size stays the same -- possibly deleting the reference to the internal icon, but not the icon information itself.

This explains why application aliases are different sizes: the developers would have made icons of varying quality and sizes.

Anyway, that was a fun bit of investigative work to keep my mind occupied on an afternoon off.

26th February 2010, 09:59 PM
Nice investigation banjo!