哪些策略和工具可用于查找 .NET 中的内存泄漏? [英] What strategies and tools are useful for finding memory leaks in .NET?

查看:32
本文介绍了哪些策略和工具可用于查找 .NET 中的内存泄漏?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写了 10 年 C++.我遇到了内存问题,但可以通过合理的努力来解决.

I wrote C++ for 10 years. I encountered memory problems, but they could be fixed with a reasonable amount of effort.

在过去的几年里,我一直在编写 C#.我发现我仍然有很多内存问题.由于不确定性,它们很难诊断和修复,而且因为 C# 的理念是,当您非常确定这样做时,您不应该担心这些事情.

For the last couple of years I've been writing C#. I find I still get lots of memory problems. They're difficult to diagnose and fix due to the non-determinancy, and because the C# philosophy is that you shouldn't have to worry about such things when you very definitely do.

我发现的一个特殊问题是我必须明确处理和清理代码中的所有内容.如果我不这样做,那么内存分析器并没有真正的帮助,因为有太多的箔在漂浮,你无法在他们试图向你展示的所有数据中找到泄漏.我不知道是我的想法有误,还是我拥有的工具不是最好的.

One particular problem I find is that I have to explicitly dispose and cleanup everything in code. If I don't, then the memory profilers don't really help because there is so much chaff floating about you can't find a leak within all the data they're trying to show you. I wonder if I've got the wrong idea, or if the tool I've got isn't the best.

什么样的策略和工具可用于解决 .NET 中的内存泄漏?

What kind of strategies and tools are useful for tackling memory leaks in .NET?

推荐答案

当我怀疑内存不足时,我会使用 Scitech 的 MemProfiler泄漏.

I use Scitech's MemProfiler when I suspect a memory leak.

到目前为止,我发现它非常可靠和强大.它至少有一次拯救了我的培根.

So far, I have found it to be very reliable and powerful. It has saved my bacon on at least one occasion.

GC 在 .NET IMO 中工作得很好,但就像任何其他语言或平台一样,如果你编写了糟糕的代码,就会发生糟糕的事情.

The GC works very well in .NET IMO, but just like any other language or platform, if you write bad code, bad things happen.

这篇关于哪些策略和工具可用于查找 .NET 中的内存泄漏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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