c++/c中free已经free过的内存会出现的现象
来源:互联网 发布:数据库语句大全 编辑:程序博客网 时间:2024/05/16 00:55
/********************************************************************** 测试多次free的后果***********************************************************************/#include<iostream>#include<cstdio>using namespace std;int main(){int *p = (int *)malloc(100);free(p);cout<<"已经free一次了,再free一次..."<<endl;free(p);return 0;}
其中的_CrtIsValidHeapPointer(pUserData)在MSDN中的描述是:
The _CrtIsValidHeapPointer function is used to ensure that a specific memory address is within the local heap. The “local” heap refers to the heap created and managed by a particular instance of the C run-time library. If a dynamically linked library (DLL) contains a static link to the run-time library, then it has its own instance of the run-time heap, and therefore its own heap, independent of the application’s local heap. When_DEBUG is not defined, calls to_CrtIsValidHeapPointer are removed during preprocessing.
为了防止迷途指针,或者是多次free()带来不可预知的异常,最好是将对应的指针,置为NULL,这样比较安全。
- c++/c中free已经free过的内存会出现的现象
- C-Free 5.0的使用
- C-Free 编译链接lib 出现错误的解决方案
- C的动态内存管理--mallac()和free()
- C 笔记 free()释放一个非malloc() 申请的内存
- C的动态内存管理--mallac()和free()
- C的动态内存管理--mallac()和free()
- C语言内存管理:malloc、calloc、free的实现
- C语言的内存分配malloc()和free()
- C语言内存管理:malloc、calloc、free的实现
- 内存管理(C语言中malloc和free的用法)
- (转)内存管理(C语言中malloc和free的用法)
- 内存管理(C语言中malloc和free的用法)
- C语言中多维数组的内存分配和释放(malloc与free)
- C语言中内存的动态管理——malloc和free
- C语言中多维数组的内存分配和释放(malloc与free)(转)
- c中内存分配与释放(malloc,realloc,calloc,free)函数内容的整理
- c 语言中内存的动态分配(allocate)和释放(free)
- maven入门基础
- hdu4091 Zombie’s Treasure Chest
- AS3实现单例模式举例
- 软件开发越来越不像工业,而更像农牧业
- 积分太少啦
- c++/c中free已经free过的内存会出现的现象
- 程序员之路——一个老程序员对刚上大学的学弟学妹的忠告
- i++和++i
- linux tar 打包命令
- 浮华落寂
- OpenGL变换顺序的理解
- C# Dictionary(字典)的键、值排序
- Oracle CHAR,VARCHAR,VARCHAR2,nvarchar类型的区别与使用
- 七夕情书之恋恋红尘