当前位置:网站首页>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 ;
边栏推荐
- How can you access the domestic server and overseas server quickly with one database?
- Acwing 2074. Countdown simulation
- sqlserver select * 能不能排除某个字段
- Pytorch损失函数总结
- 477-82(236、61、47、74、240、93)
- Customer cases | pay attention to the elderly user experience, and the transformation of bank app to adapt to aging should avoid falsehood and be practical
- mysql如何优化
- How to conduct 360 assessment
- 【正则】判断, 手机号,身份证号
- 深入理解Mysql索引底层数据结构与算法
猜你喜欢
随机推荐
Spark Learning Notes (VI) -- spark core core programming RDD action operator
智能体重秤方案主控采用CSU18M91
关于OpenFeign的源码分析
JMeter distributed pressure measurement
Message rejected MQ
be based on. NETCORE development blog project starblog - (16) some new functions (monitoring / statistics / configuration / initialization)
数据库概论 - MySQL的简单介绍
flask_restful中reqparse解析器继承
[机缘参悟-52]:交浅言深要因人而异
Explain详解
图解 SQL,这也太形象了吧!
Deeply understand the underlying data structure and algorithm of MySQL index
impala 执行计划详解
mysql如何优化
A new paradigm of distributed deep learning programming: Global tensor
Spark: ranking statistics of regional advertising hits (small case)
Leetcode 207. curriculum (July 26, 2022)
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
2022牛客多校第二场的J -- 三分做法









