title: OutOfMemoryError calling XmlSerializer.Deserialize() - not related to XML size!
body: <p>This is a really crazy bug. The following is throwing an <code>OutOfMemoryException</code>, for XML snippits that are very short and simple (e.g., <code>&lt;ABC def='123'/&gt;</code>):</p>
  
  <pre><code>public static T DeserializeXmlNode&lt;T&gt;(XmlNode node)
  {
      try
      {
          return (T)new XmlSerializer(typeof(T))
              .Deserialize(new XmlNodeReader(node));
      }
      catch (Exception ex)
      {
          throw; // just for catching a breakpoint.
      }
  }
  </code></pre>
  
  <p>I read in <a href="http://msdn.microsoft.com/en-us/magazine/cc163491.aspx#S5" rel="nofollow noreferrer">this MSDN article</a> that if I were using XmlSerializer with additional parameters in the constructor, I'd end up generating un-cached serializer assemblies every time it got called, causing an <em>Assembly Leak</em>. But I'm not using additional parameters in the constructor. It also happens on the first time it is called in a freshly started AppDomain, so that doesn't make sense either.</p>
  
  <p>What gives?</p>