I finally figured out why the Sitemap was getting a memory exceeded error. I had a sub-category id which was the same as its master category id on 1 product out of 26,604 products. That was enough to crash the program. I fixed it and now everything works perfectly.

Danny