The file is generated when it's called each week by google; the files size is a constant of under like 8k. The links are built when it's called each week by google's sitemap crawler.
But you have the rest, basically google hits your map and grabs the links, and lists them in its discovery database