I
ian
Hi, I've got the weirdest garbage collection problem - I'd appreciate any
advice you've got.
1. A class 'X' in a system I'm working on contains a reference to an
XmlDocument, populated via LoadXML.
2. Objects of type X are reused alot so different XML is loaded numerous
times.
3. If I keep this reference, the system looses more and more memory until it
hangs (> a gig of memory). If I replace this reference with a WeakReference
that holds the XMLDocument, my memory stays reasonably low and constant.
Can anyone understand this behaviour? I think it's safe to assume the
WeakReference is the only reference to the XML doc as otherwise the GC
wouldn't kill it. But then, if this is the only reference then why isn't the
memory being released when the XML is replaced normally?
Please don't suggest re-architecting the system - it's a mess, and there's
nothing I can do about it.
Cheers for any help.
advice you've got.
1. A class 'X' in a system I'm working on contains a reference to an
XmlDocument, populated via LoadXML.
2. Objects of type X are reused alot so different XML is loaded numerous
times.
3. If I keep this reference, the system looses more and more memory until it
hangs (> a gig of memory). If I replace this reference with a WeakReference
that holds the XMLDocument, my memory stays reasonably low and constant.
Can anyone understand this behaviour? I think it's safe to assume the
WeakReference is the only reference to the XML doc as otherwise the GC
wouldn't kill it. But then, if this is the only reference then why isn't the
memory being released when the XML is replaced normally?
Please don't suggest re-architecting the system - it's a mess, and there's
nothing I can do about it.
Cheers for any help.