Windows 7 清理 C++ 内存泄漏? [英] Windows 7 cleans up C++ memory leaks?

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

问题描述

只是为了好玩,我创建了一个项目,该项目创建了大约 5 GB 的内存并且没有删除它.只要应用程序正在运行,就会存在内存泄漏".当我关闭应用程序时,内存在 2 秒内恢复正常,就好像我的程序从未运行过一样.所以必须提出问题.

Just for fun I created a project that created about 5 GB of memory and did not delete it. As long as the application is running that "memory leak" is there. The second I close my application the memory within 2 seconds is back down to normal as if my program never ran. So the questions have to be asked.

Windows 7 是否会在不良程序完成后清理内存泄漏?

Does Windows 7 clean up memory leaks from bad programs when they are done?

所有 Windows 版本都这样做吗?

Do all Windows versions do this?

Linux 和 Mac OS X 环境会这样做吗?

Will Linux and Mac OS X environments do this?

推荐答案

当程序终止时,操作系统会回收之前分配给它的所有内存.清理内存泄漏可能是这种感知的副产品,但操作系统实际上并不这么认为.它不知道程序一直在泄漏内存,只知道它已经分配了它.

When the program terminates, the operating system reclaims all the memory that had previously been allocated to it. Cleaning up memory leaks may be a perceived by-product of this, but the OS does not actually see it that way. It does not know that the program had been leaking memory, just that it had allocated it.

这篇关于Windows 7 清理 C++ 内存泄漏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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