最佳内存泄漏定义 [英] The Best Memory Leak Definition

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

问题描述

我觉得开发人员在谈论内存泄漏,但是当您问他们什么意思时,很多人都不知道.为了防止这些情况,让我们决定一个.

I feel like developers talk about memory leaks but when you ask them what that means many have no idea. To prevent these situations, let's decide on one.

请没有维基百科的定义...

Please no Wikipedia definitions...

您对a的最佳定义是什么 内存泄漏以及什么是最佳方法 阻止他们?

What is your best definition of a memory leak and what is the best way to prevent them?

推荐答案

有两个定义(至少对我而言):

There are two definitions (at least for me):

朴素的定义:无法释放无法访问的内存,该内存在分配过程的执行过程中无法再由任何进程再次分配.多数情况下,可以使用GC(垃圾收集)技术将其治愈,也可以通过自动化工具进行检测.

Naive definition: Failure to release unreachable memory, which can no longer be allocated again by any process during execution of the allocating process. This can mostly be cured by using GC (Garbage Collection) techniques or detected by automated tools.

细微的定义:无法释放可访问内存,不再需要程序正常运行.使用自动化工具或不熟悉代码的程序员几乎不可能检测到这一点.从技术上讲,这不是泄漏,但它与幼稚的泄漏具有相同的含义.这不仅是我自己的想法.您可能会遇到用垃圾收集语言编写的项目,但仍然会提及在其更改日志中修复内存泄漏.

Subtle definition: Failure to release reachable memory which is no longer needed for your program to function correctly. This is nearly impossible to detect with automated tools or by programmers who are not familiar with the code. While technically it is not a leak, it has the same implications as the naive one. This is not my own idea only. You can come across projects that are written in a garbage collected language but still mention fixing memory leaks in their changelogs.

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

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