当前位置:网站首页>What is the difference between memory leak and memory overflow?
What is the difference between memory leak and memory overflow?
2022-07-01 23:21:00 【fish_ study_ csdn】
One Relevant concepts :
out of memory (out of memory): When a program requests memory , Not enough memory for it , appear out of memory; Like applying for a integer, But save it long Number that can be saved , That's memory overflow .
Memory leak (memory leak): Refers to the program after applying for memory , Unable to free requested memory space , The harm of a memory leak can be ignored , But the memory leak has serious consequences , No matter how much memory , Sooner or later it will be taken up .
difference : Memory overflow is when a program requests memory , Not enough memory for it , The system can no longer allocate the space you need ; Memory leak refers to the program after applying for memory , Unable to free requested memory space , The harm of a memory leak can be ignored , However, the number of memory leaks will lead to memory overflow .
Memory overflow is when you ask for more memory than the system can give you , The system can't meet the demand , So there's overflow .
A memory leak is when you apply to the system to allocate memory for use (new), But they don't return it after using it (delete), As a result, you can't access the memory you applied for ( Maybe you lost its address ), And the system can't assign it again to the program it needs . A plate can only hold 4 A fruit , You put on 5 individual , As a result, I fell to the ground and couldn't eat . This is overflow ! Like stacks , When the stack is full, it will cause space overflow , Call for overflow , When the stack is empty, it will cause space overflow , It's called underflow . The memory allocated is not enough to put down the sequence of data items , It's called a memory overflow .
Classify in the way that they happen , Memory leaks can be divided into 4 class :
1、 Frequent memory leaks . Code with memory leaks will be executed multiple times to , Each time it is executed, it will cause a memory leak .
2、 Occasional memory leak . Code that has a memory leak only happens under certain circumstances or operating procedures . Recurrent and episodic are relative . For a particular environment , What happens occasionally may become what happens frequently . So test environment and test method are very important to detect memory leak .
3、 One time memory leak . Code with a memory leak will only be executed once , Or because of algorithm flaws , There will always be a single memory leak . such as , Allocate memory in the class's constructor , In the destructor, the memory is not freed , So memory leaks only happen once .
4、 Implicit memory leaks . Program in the process of running the allocation of memory , But don't release memory until the end . Strictly speaking, there is no memory leak , Because eventually the program frees up all of the requested memory . But for a server program , It takes a few days to run , Weeks or even months , Not releasing memory in time can also lead to the eventual exhaustion of all the system's memory . therefore , We call such memory leaks implicit memory leaks .
From the point of view of the user using the program , Memory leaks themselves don't do any harm , As a general user , There is no memory leak at all . The real danger is the accumulation of memory leaks , This will eventually consume all the memory of the system . From this perspective , One time memory leaks don't hurt , Because it doesn't pile up , The implicit memory leak is very harmful , Because it is more difficult to detect than frequent and accidental memory leaks
边栏推荐
- RPA: Bank digitalization, business process automation "a small step", and loan review efficiency "a big step"
- Groups and ranges of regular series
- Paramètres communs de matplotlib
- Compare the version number [double pointer to intercept the string you want]
- flutter Unable to load asset: assets/images/888.png
- 认识线程
- Jielizhi, production line assembly link [chapter]
- plain framework的实际应用和扩展
- Matplotlib常用設置
- mysql ---- Oracle中的rownum转换成MySQL
猜你喜欢
Jielizhi, production line assembly link [chapter]
What is the mosaic tailgate?
2022安全员-C证考试题模拟考试题库及模拟考试
从第三次技术革命看企业应用三大开发趋势
2022年起重机司机(限桥式起重机)考试试题及模拟考试
【小程序】通过scroll-view组件实现左右【滑动】列表
Yoga27 multidimensional all-in-one computer with excellent appearance and high-end configuration
Jielizhi Bluetooth headset quality control and production skills [chapter]
CADD课程学习(3)-- 靶点药物相互作用
“35岁,公司老总,月薪2万送外卖“:时代抛弃你,连声再见都没有
随机推荐
攻防演习防御体系构建之第三篇之建立实战化的安全体系
2022 R1 fast opening pressure vessel operation test questions and answers
Design of ESP automatic download circuit
每日三题 6.28
Force buckle 710 Random numbers in the blacklist
关于游戏性能优化的一些感想
STM32F030F4驱动TIM1637数码管芯片
typescript枚举
Huisheng Huiying 2022 intelligent, fast and simple video editing software
Summary of "performance testing" of software testing, novice will know the knowledge points on the road
91. (cesium chapter) cesium rocket launch simulation
【Swoole系列1】在Swoole的世界中,你将学习到什么?
Understanding threads
2022年R1快开门式压力容器操作考题及答案
Multiple smart pointers
【Kotlin 第三方 】coil koltin协程图片加载库Coil类似Glide的图片加载第三方
常见的二十种软件测试方法详解(史上最全)
mysql ---- Oracle中的rownum转换成MySQL
Istio、eBPF 和 RSocket Broker:深入研究服务网格
You probably haven't noticed the very important testing strategy in your work