免费后会发生内存什么()? [英] What happens to memory after free()?

查看:128
本文介绍了免费后会发生内存什么()?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道,你的硬盘驱动器,如果你删除一个文件,数据不(立即)不见了。数据仍然存在,直到它被覆盖。我在想,如果在内存中存在一个类似的概念。说我分配256个字节的字符串,则该字符串仍在内存浮动后的某个地方我免费(),直到它被覆盖?

I know that on you hard drive, if you delete a file, the data is not (instantly) gone. The data is still there until it is overwritten. I was wondering if a similar concept existed in memory. Say I allocate 256 bytes for a string, is that string still floating in memory somewhere after I free() it until it is overwritten?

推荐答案

一般情况下,它确实呆在身边,除非你明确地覆盖前免费字符串ING它(如人有时候做密码)。一些库实现自动覆盖解除分配的内存赶上访问,但并非在释放模式完成。

Generally, it does stay around, unless you explicitly overwrite the string before freeing it (like people sometimes do with passwords). Some library implementations automatically overwrite deallocated memory to catch accesses to it, but that is not done in release mode.

这篇关于免费后会发生内存什么()?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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