OutOfMemoryError异常调用XmlSerializer.Deserialize() - 不相关的XML的大小!不相关、异常、大小、OutOfMemoryError

2023-09-03 16:12:46 作者:我要破茧而出

这是一个非常疯狂的错误。以下是抛出 OutOfMemoryException异常,对XML snippits是非常简短(例如,< ABC DEF ='123'/> ):

This is a really crazy bug. The following is throwing an OutOfMemoryException, for XML snippits that are very short and simple (e.g., <ABC def='123'/>):

public static T DeserializeXmlNode<T>(XmlNode node)
{
    try
    {
        return (T)new XmlSerializer(typeof(T))
            .Deserialize(new XmlNodeReader(node));
    }
    catch (Exception ex)
    {
        throw; // just for catching a breakpoint.
    }
}

我读这个MSDN文章的,如果我是使用与XmlSerializer的构造函数中附加参数,我想最终在每次得到调用时产生非缓存串行器组件,引起的大会泄漏的。但我不使用构造函数的附加参数。它也发生在第一次被调用的新鲜开始的AppDomain,这样就没有意义了无论是。

I read in this MSDN article 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 Assembly Leak. 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.

怎么办?

推荐答案

好了,最后回答我的问题是不会帮助大家,遇到这种情形,但我的一些同事也遇到了这个月后在不同的系统用不同的产品。当他们发现我的岗位在这里SO个月后,她想知道如果我真的已经解决与否,因为没有解决方案是在这里接受的笑了起来。

Well, the final answer to my question isn't going to help everyone that encounters this, but some of my coworkers also encountered this months later on a different system with a different product. The laughed when they found my post here on SO months later and wondered if I actually had solved it or not, since no solution was accepted here.

最终的解决方案无关,与反序列化的问题。相反,它涉及到完全卸载和安装Oracle的一个全新的副本 ODP.NET 数据库客户端,提供许多如果不是所有的应用程序使用。

The final solution has nothing to do with problems Deserializing. Instead, it involved completely uninstalling and installing a brand new copy of Oracle ODP.NET database client, the provider many if not all of our applications use.

根据传闻,看来这个问题出现在ODP.NET组件,其中,随后得到了通过虚拟机的克隆传播到其他系统不当修补版本。

Based on anecdotal evidence, it seems this problem arises on improperly patched versions of ODP.NET assemblies, of which subsequently got propagated to other systems via virtual machine clones.

当ODP.NET完全除去,和一个新的兼容版本被从Oracle网站检索并安装,问题完全消失。

When ODP.NET was completely removed, and a new compatible version was retrieved from the Oracle website and installed, the problem disappeared completely.

该假说是一个可用的(但腐败)ODP.NET驱动程序有不安全code,并重复地覆盖反序列化法附近的.NET保护存储区第一次使用之后。如果反序列化在之前的任何ODP.NET调用调用时,它会工作得很好。然而,所有的后续调用使用任何ODP.NET调用会惨遭失败后反序列化。

The hypothesis is that a usable (but corrupt) ODP.NET driver has unsafe code and was repeatably overwriting the .NET protected memory area near the Deserialize method after first use. If Deserialize was called before any ODP.NET invocations, it would work just fine. However, all subsequent calls to Deserialize after using any ODP.NET calls would fail miserably.

在两个不同的产品的最终解决这一点,现在已经解决了的两次的是得到一个好/新鲜/清洁/新ODP.NET安装的副本。

The final solution to this that has now been resolved twice in two distinct products is to get a good/fresh/clean/new copy of ODP.NET installed.

不是pretty的......但是这就是解决它。

Not pretty... but that's what solved it.

 
精彩推荐
图片推荐