Is leaked memory freed up when the program exits?(程序退出时是否释放了泄漏的内存?)
问题描述
如果我在不知情的情况下编写了内存泄漏,然后应用程序终止,泄漏的内存是否被释放?
If I programmed — without knowing it — a memory leak, and the application terminates, is the leaked memory freed?
推荐答案
是的,内存泄漏"只是进程不再引用的内存,因此无法再释放.操作系统仍会跟踪分配给进程的所有内存,并在该进程终止时将其释放.
Yes, a "memory leak" is simply memory that a process no longer has a reference to, and thus can no longer free. The OS still keeps track of all the memory allocated to a process, and will free it when that process terminates.
在绝大多数情况下,操作系统会释放内存 - 就像 Windows、Linux、Solaris 等正常风格"的情况一样.但重要的是要注意,在各种实时环境等特殊环境中操作系统程序终止时可能不会释放内存.
In the vast majority of cases the OS will free the memory - as is the case with normal "flavors" of Windows, Linux, Solaris, etc. However it is important to note that in specialized environments such as various Real-Time Operating Systems the memory may not be freed when the program is terminated.
这篇关于程序退出时是否释放了泄漏的内存?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:程序退出时是否释放了泄漏的内存?
- 从python回调到c++的选项 2022-11-16
- 与 int by int 相比,为什么执行 float by float 矩阵乘法更快? 2021-01-01
- 一起使用 MPI 和 OpenCV 时出现分段错误 2022-01-01
- Stroustrup 的 Simple_window.h 2022-01-01
- 如何对自定义类的向量使用std::find()? 2022-11-07
- 近似搜索的工作原理 2021-01-01
- 使用/clr 时出现 LNK2022 错误 2022-01-01
- 静态初始化顺序失败 2022-01-01
- STL 中有 dereference_iterator 吗? 2022-01-01
- C++ 协变模板 2021-01-01