free 释放内存
http://www.cplusplus.com/reference/cstdlib/free/
free
void free (void* ptr);
A block of memory previously allocated by a call to malloc, calloc or realloc is deallocated, making it available again for further allocations.
If ptr does not point to a block of memory allocated with the above functions, it causes undefined behavior.
If ptr is a null pointer, the function does nothing.
Notice that this function does not change the value of ptr itself, hence it still points to the same (now invalid) location.
Parameters
Return Value
none
Example
|
|
This program has no output. It just demonstrates some ways to allocate and free dynamic memory using the C stdlibfunctions.
Data races
Only the storage referenced by ptr is modified. No other storage locations are accessed by the call.
If the function releases a unit of storage that is reused by a call to allocation functions (such as calloc or malloc), the functions are synchronized in such a way that the deallocation happens entirely before the next allocation.
Exceptions (C++)
No-throw guarantee: this function never throws exceptions.
If ptr does not point to a memory block previously allocated with malloc, calloc or realloc, and is not a null pointer, it causes undefined behavior.
See also
- malloc
- Allocate memory block (function )
- calloc
- Allocate and zero-initialize array (function )
- realloc
- Reallocate memory block (function )
free 释放内存的更多相关文章
- CentOS7清理yum缓存和释放内存方法
清理yum缓存 清理yum缓存使用yum clean 命令,yum clean 的参数有headers, packages, metadata, dbcache, plugins, expire-ca ...
- 在dll里malloc/new/cvCreate分配内存,在exe里free/Releases释放内存时会出错。
写了个程序,在DLL中用malloc分配了一块内存,但是在exe程序中释放,结果程序crash,原因就是:其原因可能是堆被损坏,这也说明 TestMySticker.exe 中或它所加载的任何 DLL ...
- PHP unset()函数销毁变量 但没有实现释放内存
<?PHP $a = "hello";$b = &$a;unset( $b );echo $a; // 输出 helloecho $b; // 报错$b = &quo ...
- PHP unset销毁变量并释放内存
PHP的unset()函数用来清除.销毁变量,不用的变量,我们可以用unset()将它销毁.但是某些时候,用unset()却无法达到销毁变量占用的内存!我们先看一个例子: <?php $s=st ...
- vector容器删除某些元素且释放内存
1,size和capacity size: 指目前容器中实际有多少元素,对应的resize(size_type)会在容器尾添加或删除一些元素,来调整容器中实际的内容,使容器达到指定的大小. capac ...
- android回收AnimationDrawable动画的每一帧的图片资源,而释放内存
回收每一帧的图片,释放内存资源 private void tryRecycleAnimationDrawable(AnimationDrawable animationDrawables) { if ...
- Linux手动释放内存
手动释放内存 1.sync将内存中的缓存写入磁盘 2. to free pagecache, use echo 1 > /proc/sys/vm/drop_caches; to f ...
- redis采用tcmalloc导致无法释放内存的问题
from:http://wangneng-168.iteye.com/blog/2100379 redis使用tcmalloc管理内存,当删除了redis的key后,通过redis的info命令查看内 ...
- python里的del变量无法立刻释放内存的解决办法
最近在python开发的时候,用到了一些很占用内存的操作,导致后续程序执行很慢甚至无法执行.探索了一下,最终解决了这个问题. 截图解释: python变量占用了内存,仅仅通过del变量的方式,只是让这 ...
- /MT、/MD编译选项,以及可能引起在不同堆中申请、释放内存的问题
一.MD(d).MT(d)编译选项的区别 1.编译选项的位置 以VS2005为例,这样子打开: 1) 打开项目的Property Pages对话框 2) 点击左侧C/C ...
随机推荐
- 8 -- 深入使用Spring -- 3...1 Resource实现类FileSystemResource
8.3.1 Resource实现类------FileSystemResource:访问文件系统的资源的实现类 3.访问文件系统资源 Spring提供的FileSystemResource类用于访问文 ...
- PHPDragon设计结构
PHPDragon的设计思路来源至YII框架,可以吐槽作者本人完全copy,但希望在后面,会慢慢的走出一条不同的分支. 1.Dragon.php(DragonBase.php)入口文件,负责程序的自动 ...
- Git Step by Step – (3) Git对象模型
前面一篇文章介绍了本地仓库的一系列操作,下面我们将进一步了解Git的工作原理,介绍Git对象模型. 刚开始使用Git的时候,对Git对象模型.工作原理并不理解,但是经过一段时间的使用.熟悉之后,然后再 ...
- 利用广播实现ip拨号——示例
1.创建activity_main.xml <LinearLayout xmlns:android="http://schemas.android.com/apk/res/androi ...
- [Ubuntu] apt 添加第三方库
1. 方法一:直接在 /etc/apt/sources.list 添加第三方库. $ sudo vi /etc/apt/sources.list 在其中添加: deb http://archive.s ...
- [Git] 解决 insufficient permission for adding an object to repository database
[环境] OS: CentOS 6.5 Git: 1.7.1 [症状描述] Git 中心仓库路径 ~/project.git,克隆库路径 ~/project.clone,克隆库中包含一个文件 ~/pr ...
- 深入理解tomcat9---源码构建
环境准备: tomcat9源码 maven(bin目录加入path系统环境变量) jdk8 idea 源码构建步骤: 1. 在解压缩的源码目录下新建pom.xml文件,内容如下: <?xml v ...
- Qt编写气体安全管理系统(界面超漂亮)
自从把Qt样式表葵花宝典这个pdf文件看完以后,将所有的qss内容都轮了一遍,还写了个皮肤生成器工具,https://blog.csdn.net/feiyangqingyun/article/deta ...
- Elasticsearch学习之快速入门案例
1. document数据格式 面向文档的搜索分析引擎 (1)应用系统的数据结构都是面向对象的,复杂的(2)对象数据存储到数据库中,只能拆解开来,变为扁平的多张表,每次查询的时候还得还原回对象格式,相 ...
- sencha touch 常见问题解答(26-50)
26.sencha touch在华为.红米等部分手机下hide事件失效,msgbox无法关闭怎么办 答:请看http://www.cnblogs.com/cjpx00008/p/3535557.htm ...