Tom, I think it is a gift but I think (hope) it can be developed too.
For me it takes daily practice. Repeat the same tunes everyday. After awile, there are some tunes that I never forget and other seem to fade away.
Last summer I had two months off from my day job and I worked up about 40 tunes. It took me about an hour to get through all those tunes. However, now that I'm back working and I got out of the routine and I'm starting to forget some of the songs.
It's wierd how the brain works. The other night I was trying to play through a Bach Two Part Invention that I had memorized. I kept forgeting some of the parts. Rather than look at the score, I just took a break. The next day I played through the piece fine just fine.