Leak Found in the .NET XmlSerializer

We finally found another leak in our Citrix WinForms app.  Early tests show this one to be huge, so we are optimistic that this will clear up most of our problems.  Apparently the XmlSerializer creates dynamic assemblies, but they only get reused if you stick to the simplist constructors.  We are using one of the more complex constructors, so we were essentially leaking dynamic assemblies since .net provides no way to remove assemblies from an AppDomain.  I can't take credit for finding the problem, one of my colleagues here did that, but I found the solution -- just create it once and reuse it.  Its also interesting to note that now that I know what to look for, its easy to find other people that have ran into this before, like Joseph Cooney and Scott Hanselman.
Published Wednesday, February 11, 2004 4:19 PM by PaulWilson

Comments

# re: Leak Found in the .NET XmlSerializer

Paul, whilst I've not run in to this problem it would be benificial if you could explain how you "just create it once and reuse it" - just in case I (or others) run in to the issue.

:-)

Wednesday, February 11, 2004 5:08 PM by Phil Winstanley [ASP.NET MVP]

# re: Leak Found in the .NET XmlSerializer

Create the serializer once, and keep a reference to it.

Wednesday, February 11, 2004 8:02 PM by JosephCooney

# re: Leak Found in the .NET XmlSerializer

(sorry - I should have mentioned that my previous post was in answer to Phil's question).

Wednesday, February 11, 2004 8:03 PM by JosephCooney

# .NET Memory Management and Garbage Collection

Saturday, February 14, 2004 2:07 PM by TrackBack

# Another .NET leak - this time in the XmlSerializer class.

Thursday, March 25, 2004 1:15 PM by TrackBack

# Enabling Evil - Tunnelling Xml within Xml using the XmlSerializer and some Magic

Tuesday, March 22, 2005 3:11 PM by TrackBack

Leave a Comment

(required) 
(required) 
(optional)
(required)