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

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

问题描述

只是为了好玩,我创建了一个项目创建约5 GB的内存,并没有删除它。只要应用程序正在运行,内存泄漏是存在的。第二个我关闭我的应用程序的内存在2秒内恢复正常,如果我的程序从来没有运行。



Windows 7在完成后会清除坏程序的内存泄漏吗?



Linux和Mac OS X环境能做到这一点吗?

解决方案

程序终止时,操作系统会回收先前分配给它的所有内存。清除内存泄漏可能是一个被察觉的副产品,但是操作系统实际上并没有这样看到。它不知道程序泄漏了内存,只是它已经分配了它。


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.

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

Do all Windows versions do this?

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天全站免登陆