Bob, the new boss, has been running memory tests with BoundsChecker and had noticed that a particular function was opening a number of documents that weren't being closed. My initial assumption was that this was because of a failure in reference counting the document that was preventing the destructor from being called, so I dropped a bunch of TRACE statements into the code so I could watch files opening, closing, and being destroyed.
At the end of the run, I closed the Server normally and 33 unnamed (presumably temporary) files were closed. *ick*
So we went and looked at the function that Bob had located. It turned out that the function opened a temporary document and never asked for it to be closed. However, the document was being correctly registered with the document template, so when the application was closed, it was found and killed.
I added a bunch of try/catch logic to make sure that the document died on schedule. And things appear to be better now.
Apparently, though, my first assumption should have been that the person who wrote the code would forget to close the document. Not an assumption I like to make, but it would have saved some time...