From a purely technical aspect, there is essentially no additional cost to generating a permalink for every comment.
As other users have mentioned in the comments (and I will repeat), every message sent on the chat system have a specific ID number stored in the database. In fact, you can go to the Stack Exchange Data Explorer and see sort of how these values are stored. Such as to keep this conversation moving, there'll be an
When you get a permalink for the comment, it's in the following format:
That ID just points to whatever record exists in the database, which is a very light query to run.
I think you might be getting confused by the "traditional" website model, where every folder and file is physical and actually present on a server's hard drive somewhere (and incurs storage fees from the likes of GoDaddy or similar).
The above idea can break down very simply with modern web applications. Instead of storing raw files and getting them as suggested by the URL, we can just pass the URL itself (
transcript/message/<message_id> to the server at
chat.stackoverflow.com). The web application running at the server can do whatever it wants, and return whatever it wants. In this case, Stack Exchange is using this structure to refer to objects in their database as opposed to a direct file. Basically, imagine that the URL is a variable instead of a file.
In fact, you can even demonstrate this to yourself. Someone made a cool script you can run that demonstrates how this sort of works. For example, if I make a request to
localhost:8080/hello/stackexchange, the script will spit out exactly what it gets:
----- Request Start ----->
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.110 Safari/537.36
Accept-Encoding: gzip, deflate, sdch, br
<----- Request End -----
As you can see, it really is just a meaningless variable. I can very easily write a program to return whatever I want when I hit that URL, without any backing file. In fact, it would even be possible to write a little program that will take whatever I pass in as a path, and return a string (so
hello stackexchange). I'm not storing every possible word in existence. Instead, I'm generating them on-the-fly using code. Stack Exchange does the exact same thing.
Now, this doesn't mean there's no cost either. You need to store the chat message record in the database (which might be a few kilobytes -- very cheap (effectively free) in today's world). Similarly, whatever server is listening at
chat.stackexchange.com must actually be running and talking to the internet and the database server (which uses bandwidth).
To give you a demonstration, I've written a Python script to do something very similar to what I mentioned above, as an example of dynamic page generation. Run it, and point your web browser to
localhost:9001/hello/world to see it in action. Play around with the URLs. As you can see, there's no storage at all -- it's all dynamically generated. The only cost here is the disk space the script is taking (< 1 KB), and the bandwidth used for your computer to talk to the script (negligible at best, and in fact nonexistent because you're talking to your own computer).
In a sense, there's also a cost inasmuch as each ID is unique, and there are only so many IDs, but this can easily be fixed when the time comes.
TL;DR: It's not like storing a unique file. It's just a very light database query and storage itself to Stack Exchange is really really cheap -- on the order of a fraction of a fraction of a cent per message in the DB.