为什么内存泄漏很常见? [英] Why are memory leaks common?

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

问题描述

这是由于程序员对内存是如何动态分配和释放的基本误解造成的吗?是因为自满吗?

Is it due to basic misunderstandings of how memory is dynamically allocated and deallocated on the programmer's part? Is it due to complacency?

推荐答案

没有.这是由于跟踪每个内存分配所需的大量记帐.谁负责分配内存?谁负责释放它?确保使用相同的 API 来分配和释放内存等...确保捕获所有可能的程序流并在每种情况下进行清理(例如,确保在捕获错误或异常后进行清理).名单还在继续……

No. It's due to the sheer amount of accounting it takes to keep track of every memory allocation. Who is responsible for allocating the memory? Who is responsible for freeing it? Ensuring that you use the same API to allocate and free the memory, etc... Ensuring you catch every possible program flow and clean up in every situation(for example, ensure you clean up after you catch an error or exception). The list goes on...

这篇关于为什么内存泄漏很常见?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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