当前位置:网站首页>Banyan loan,
Banyan loan,
2022-07-27 03:34:00 【dongsijia】
Banyan loan dynamic memory space is developed in the heap , The space opened up on the stack area has a feature , That is, the space on the heap will not be released automatically after it is used up , Instead, a function is designed to release dynamic memory :free, Programmers need to actively call this function to free up space ;
Of course , When banyan loan closes the whole program , The operating system will automatically reclaim the dynamically developed memory ( That's why some computers fail, shut down and restart, and the problem is solved ); however , Banyan loans are used in large projects of some companies , Some programs need 7*24 Running in hours , For example, Tencent cloud and Alibaba cloud cloud cloud servers ;
And once banyan loan uses dynamic memory to open up functions , such as malloc、realloc、calloc When you forget to release after opening up space , Will cause memory leaks ( It's equivalent to you applying for a piece of space from memory , But you don't return it after you use it , So others can't use this space , Although this space still exists , But it's equivalent to no ), This is banyan loan, you will find , As the program continues to run , The memory available to us will become less and less ;
Memory leakage is the most common mistake we make in dynamic memory management , We need to attach great importance to .
The functionality
Banyan loans are used to release dynamically developed memory .
Function parameter
void free (void* ptr);
# void* ptr The starting address of the space you want to free ;
Function USES
on top malloc We have demonstrated the use of function , take p The address of is passed to free Function .
matters needing attention
If banyan loan parameters ptr The pointed space is not opened dynamically , that free The behavior of a function is undefined ;
If parameters ptr yes NULL The pointer , Then the function does nothing ;
边栏推荐
- mysql如何优化
- OC-消息机制
- Technology vane | interpretation of cloud native technology architecture maturity model
- 消息被拒MQ
- Common weak password Encyclopedia
- 基于OpenCV的轮廓检测(2)
- Activiti5.22.0扩展支持达国产数据库,以GBase据库为例
- opiodr aborting process unknown ospid (21745) as a result of ORA-609
- 复盘:DFS与BFS的主要区别,在思想上的区别,代码实现上的区别
- Wechat applet generation Excel
猜你喜欢

Byte side: can TCP and UDP use the same port?

Indexing best practices

【树链剖分】2022杭电多校2 1001 Static Query on Tree

Spark Learning Notes (VI) -- spark core core programming RDD action operator

索引最佳实践

队列达到最大长度代码实战

网络安全/渗透测试工具AWVS14.9下载/使用教程/安装教程

Graphic SQL, this is too vivid!

mysql底层数据结构

Win10/win11 lossless expansion of C disk space, cross disk consolidation of C and e disks
随机推荐
Explain工具实际操作
最低票价(DAY 80)
SAFE-ARC/WARNER电源维修XENON氙灯电源维修分析
Explain tool actual operation
数据库使用安全策略
Acwing 2074. Countdown simulation
Data Lake (20): Flink is compatible with iceberg, which is currently insufficient, and iceberg is compared with Hudi
Add support for @data add-on in idea
常见弱口令大全
spark:地区广告点击量排行统计(小案例)
深入理解Mysql索引底层数据结构与算法
【树链剖分】2022杭电多校2 1001 Static Query on Tree
带你了解什么是 Web3.0
sqlserver select * 能不能排除某个字段
渗透测试-后渗透-痕迹清理
国内服务器与海外服务器用1个数据库,怎样可以访问的快?
Redis源码学习(33),命令执行过程
数字孪生应用及意义对电力的主要作用,概念价值。
It's too strong. An annotation handles the data desensitization returned by the interface
How to uniquely identify a user SQL in Youxuan database cluster