Big*_*toe 1 .net c# memory-leaks
I'm trying to track down a memory leak in an application using ANTS profiler. I tracked it down to the Garbage collector where we have a list of objects System.Transactions.SafeIUnknown that sit there forever in the garbage collector, are in the finalizer queue but never get released.
I can find not documentation what so ever on the System.Transactions.SafeIUnknown nor can I determine what would create or reference this, it's nothing intentional on our part.
I am hoping someone out there may have some knowledge about this. It's a small leak of 20bytes but when our apps runs for days on end the leak builds up and we have millions of these waiting finalization and it starts to eat up lots and lots of memory.
Anyone any ideas where to go from here?
我已将其跟踪到正在使用的特定库中。通过这个特定的库执行任何SQL语句后,它似乎被遗忘了。声明没有包装在事务中,而是通过通用类型的相当复杂的循环执行,当前看起来像是双重三倍间接,委托被传递给运动并包装在闭包中,闭包中可以包裹更多的闭包。我将继续尝试精确地将其绑定,我的第一个调用端口是尝试查看是否可以使用类似的机制来重现它。
SafeIUnknown派生自SafeHandle。那就是实现终结器的类。特殊的是,它的完成代码在关键执行区(CER)中运行。这种代码提供了执行保证,可以抑制异常。终结器运行SafeIUnknown.ReleaseHandle(),它调用Marshal.Release()释放由SafeIUnknown包装的COM接口指针。
在完成队列中看到很多此类包装器,表明Marshal.Release()调用引发异常。防止包装程序完成。确切找出它引发异常的原因将非常棘手。这是非托管代码轰炸,您几乎没有提示可以找到原因。95%的情况是堆损坏,这是一个很难解决的问题。最重要的是,因为这可能不是您的代码,并且您没有任何来源。
您应该能够在良好的非托管代码调试器(例如WinDbug)中获得断点,并获得第一个机会异常。获取调试符号对于使堆栈跟踪具有任何意义是必不可少的。但是,从那里开始可能还很遥远。考虑从Microsoft支持获得帮助。或诸如重建机器之类的剧烈动作。祝你好运!
| 归档时间: |
|
| 查看次数: |
977 次 |
| 最近记录: |