Well, so far I've not been able to find an actual memory leak with documents, but I have discovered that SPDocuments ARE actually managed by the garbage collector.
Apparently I converted SPDocument over and then forgot about it.
So, the upshot is that the old document will linger for some time until the next garbage collection pass. That wouldn't be an issue, except some stuff currently ties extra cleanup (like tearing down namedviews) too tightly to freeing memory, when it should really be done earlier.
In the short term, the thing to do IS in fact to force a garbage collection when the document is closed. Apologies to the people I've gotten in arguments with over this... you all were right.
The only trick is that the forced collection pass can't happen too early -- e.g. if there are still references to the old SPDocument in local variables somewhere in the call chain, or from other garbage-collected objects, that will prevent it from being collected.
-mental
participants (1)
-
MenTaLguY