C#内存泄露? [英] C# memory leak?

查看:102
本文介绍了C#内存泄露?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有过一个DataTable循环,并推动这些进入一些地点,如鼠尾草和SQL表C#应用程序。



虽然它曾经做工精细,莫名其妙地我现在走出一个小时后,内存异常左右运行它。我注意到在任务管理器,通过anbout 1MB的内存使用量上升每一秒,并保持要去!



我的印象是垃圾收集下会采取什么,但可以肯定我保证我使用后丢弃的任何对象。我知道没有代码很难诊断,但有很多呢,我期待更多的一般性建议。


解决方案

但可以肯定我保证我使用后丢弃任何物体




的Dispose()没有直接关系内存管理或泄漏。



您将不得不寻找那些仍然到达未使用的对象。使用一个内存分析器找出。



您可以通过免费的 CLR-探查


I have a C# application that loops through a datatable, and pushes these into some locations such as Sage and a SQL table.

While it used to work fine, I'm inexplicably now getting Out of Memory exceptions after an hour or so of running it. I've noticed in the task manager, the memory usage rises by anbout 1mb every second, and keeps on going!

I was under the impression garbage collection would take of anything, but to be sure I ensure I dispose any objects after using them. I know without code it's hard to diagnose, but there's a lot of it and I'm looking more for general advice.

解决方案

but to be sure I ensure I dispose any objects after using them

Dispose() is not directly related to memory management or leaks.

You'll have to look for unused objects that are still 'reachable'. Use a memory-profiler to find out.

You can start with the free CLR-Profiler.

这篇关于C#内存泄露?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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