小内存泄漏不再重要了吗? [英] Do Small Memory Leaks Matter Anymore?

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

问题描述

现在所有PC上的RAM通常都以GB为单位,我是否应该花时间寻找程序中所有小的(非增长的)内存泄漏?我说的是那些可能少于64个字节的漏洞,甚至是只有4个字节的一堆漏洞.

With RAM typically in the Gigabytes on all PC's now, should I be spending time hunting down all the small (non-growing) memory leaks that may be in my program? I'm talking about those holes that may be less than 64 bytes, or even a bunch that are just 4 bytes.

其中一些很难识别,因为它们不在我自己的代码中,而是可能在第三方代码中或在开发工具的代码中,而且我什至无法直接访问源代码.在这种情况下,将需要与这些产品的供应商进行长时间的沟通.

Some of these are very difficult to identify because they are not in my own code, but may be in third party code or in the development tool's code, and I may not even have direct access to the source. In those cases, it would involve lengthy communication with the vendors of these products.

我在SO处看到了第一个内存泄漏问题:内存泄漏是否还可以? ,到目前为止,该问题的第一个答案是85次,它是:否.

I have seen the number one memory leak question here at SO: Are memory leaks ever ok? and the number one answer to that, as of now voted up 85 times, is: No.

但是在这里,我谈论的是微小的泄漏,这些泄漏可能需要大量的调试,研究和沟通才能追踪.

But here I'm talking about small leaks that may take an inordinate amount of debugging, research and communication to track down.

我只是在谈论一个简单的桌面应用程序.我了解在服务器上运行的应用必须尽可能紧密.

And I'm only talking about a simple desktop app. I understand that apps running on servers must be as tight as possible.

所以我真正要问的问题是,如果我知道我有一个程序在每次运行时泄漏40个字节,这有关系吗?

So the question I am really asking is, if I know I have a program that leaks, say 40 bytes every time it is run, does that matter?


(来源: beholdgenealogy.com )


(source: beholdgenealogy.com)

另请参阅我的后续问题:哪些操作系统将释放内存泄漏吗?

Also see my followup question: What Operating Systems Will Free The Memory Leaks?

后记:我刚购买 EurekaLog 用于我的程序开发.

Postscript: I just purchased EurekaLog for my program development.

我发现亚历山大的出色文章, EurekaLog(应该知道这些事情)的作者,有关捕获内存泄漏.亚历山大在那篇文章中非常简洁地陈述了我的问题的答案:

I found an excellent article by Alexander, the author of EurekaLog (who should know these things), about catching memory leaks. In that article, Alexander states the answer to my question very well and succinctly:

尽管应用程序中的任何错误始终很严重,但存在某些错误类型,这些错误在某些环境中不可见.例如,内存或资源泄漏错误在客户端计算机上相对无害,而

While any error in your application is always bad, there are types of errors, which can be not visible in certain environments. For example, memory or resources leaks errors are relatively harmless on client machines and can be deadly on servers.

推荐答案

这完全是个人决定.

但是,如果:

所以我真正要问的问题是,如果我知道我有一个程序在每次运行时泄漏40个字节,这有关系吗?

So the question I am really asking is, if I know I have a program that leaks, say 40 bytes every time it is run, does that matter?

在这种情况下,我会拒绝.程序终止时将回收内存,因此,如果在可执行文件运行期间仅泄漏40个字节一次,那实际上是没有意义的.

In this case, I'd say no. The memory will be reclaimed when the program terminates, so if it's only leaking 40 bytes one time during the operation of an executable, that's practically meaningless.

但是,如果每次执行一些操作时,它重复泄漏40个字节,则可能更有意义.应用程序运行的时间越长,意义就越大.

If, however, it's leaking 40 bytes repeatedly, each time you do some operation, that might be more meaningful. The longer running the application, the more significant that becomes.

我想说的是,即使泄漏是无意义的"泄漏,修复内存泄漏还是很值得的.内存泄漏通常是某些潜在问题的指示器,因此了解和纠正泄漏通常会随着时间的推移使您的程序更可靠.

I would say, though, that fixing memory leaks often is worthwhile, even if the leak is a "meaningless" leak. Memory leaks are typically indicators of some underlying problem, so understanding and correcting the leak will often make your program more reliable over time.

这篇关于小内存泄漏不再重要了吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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