C#OutOfMemoryException异常 - 如何追查元凶 [英] C# OutOfMemoryException - How to track down the culprit

查看:4697
本文介绍了C#OutOfMemoryException异常 - 如何追查元凶的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个,就是与512 MB内存小的平板电脑上运行的C#/ WPF应用程序。如果是往左跑,一个OutOfMemoryException最终被抛出。这可能需要12+小时至2天发生。

I have a C#/WPF application that is meant to run on a small panel PC with 512 MB of memory. If it is left to run, an OutOfMemoryException is eventually thrown. This can take 12+ hours up to 2 days to happen.

同时使用ProcessExplorer和.NET内存分析器,我看不出有任何证据表明我的应用程序所使用的内存越来越大随着时间的推移。有一点点增长之后的垃圾收集的典型模式。

Using both ProcessExplorer and .NET Memory Profiler, I see no evidence that the memory used by my application is growing over time. There is just a typical pattern of a little growth followed by garbage collection.

我已经添加代码时引发异常打印出所有正在运行的进程及其内存信息。我目前只是等着它再次发生。我应该指出,PC是基于flash和寻呼被禁用。 512是一个硬性限制。

I've added code to print out all running processes and their memory information when the exception is thrown. I'm currently just waiting around for it to happen again. I should mention that PCs are flash based and paging is disabled. The 512 is a hard limit.

它发生在两个单独的电脑。唯一的例外是信息在两种情况下是相同的:

It has happened on two separate PCs. The exception information was the same in both cases:

Top Level Exception - System.OutOfMemoryException: Insufficient memory to continue the execution of the program.
    at System.Windows.Media.Composition.DUCE+Channel.SendCommand(Byte* pCommandData, Int32 cSize)
    at System.Windows.Media.MediaContext.EnterInterlockedPresentation()
    at System.Windows.Media.MediaContext.ScheduleNextRenderOp(TimeSpan minimumDelay)
    at System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget)
    at System.Windows.Media.MediaContext.AnimatedRenderMessageHandler(Object resizedCompositionTarget)
    at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter)
    at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)

任何有识之士的赞赏!

推荐答案

原来,各种问题引起了我的应用程序崩溃。我已经详细介绍他们在另一个在这里发表

It turns out that a variety of issues were causing my application to crash. I've detailed them in another post here.

这篇关于C#OutOfMemoryException异常 - 如何追查元凶的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆