在给定的情况下如何知道调试/配置文件挂起的C#应用​​程序 [英] How to know debug/profile hanged C# application in the given situation

查看:123
本文介绍了在给定的情况下如何知道调试/配置文件挂起的C#应用​​程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用C#编写的覆盖线程序(控制台应用程序)



运行正常,最多6到10小时后,它失败并停止,控制台不会关闭并显示最后一个成功的日志



它在文件中写入的错误日志(所有可能的)。



如果即使是IO异常,它会在Windows事件中写入



还有内存警卫和线程守护者限制程序给定限制。



停止(6-10小时后)没有任何事情发生错误日志,心跳,数据库调用,内存使用情况,我可以看到线程生成约70%的最大限制设置。



我知道这可能是内存泄漏,因为线程可能不会因数据库调用延迟而释放。 p>

我只想在这个停止的应用程序上工作,以了解确切的问题,如内存泄漏在哪里或哪个调用阻塞。



有没有可用的工具可用于这个挂起/停止的应用程序?我应该使用ANTS内存管理器,性能优化器,但所有这些工具都可以运行应用程序。



我可以得到的最多的是内存转储。



欢迎提出建议。



编辑:
最初我不想重新运行等待几个小时来调试,如果没有办法是最后一个选项。



我试图附加调试器并放置断点,它说断点当前不会打....

解决方案

你应该看看事件查看器。
然后如果您的应用程序在没有日志的情况下崩溃,可能是由于未处理的异常。
将以下代码放在主要方法中:

  Application.ThreadException + =(sender,arg)=> {log.Error(未处理的异常:+ e.Exception);}; 
Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);

祝你好运


I have mulch-threaded program (console application) written in C#

It runs fine up to 6 -10 hours later it fails and stops , console does not closes and shows the last successful log

Error logs (all possible) it writes in a file.

if even IO exception occurs it writes it in Windows Event

There are Memory Guard and Thread Guards too that limit program to given limit.

When it stops (6-10 hours later) nothing happens no error log, heart beat, database calls, memory usage, I can see the thread is spawn around 70% maximum limit set.

I know it might be a memory leak because of that threads might not be getting free due to database call latencies.

I just wanted to work on this stopped application to know the exact problem, like where is the memory leak or which call does blockage.

Are there any tools available that works on this hanged/stopped application? What should be proper way to proceed.

I used ANTS memory pro-filer, performance pro-filers but all these tools work on running applications.

What most i am can get is a Memory Dump.

Suggestions are welcome.

EDIT: Initially I don't want to rerun it wait hours to debug, if there is no way that would be the last option.

I tried to attach debugger and put breakpoints, it says "The breakpoint will not currently hit...."

解决方案

First you should have a look in the event Viewer. Then if your application crashes without logs, it could be due to an unhandled Exception. Put the following code in the main method :

Application.ThreadException += (sender, arg) => { log.Error("Unhandled exception : "+e.Exception);};
Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);

Good luck

这篇关于在给定的情况下如何知道调试/配置文件挂起的C#应用​​程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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