* Heap overflow : ceaseless new An object , Always create new objects ,
* Stack overflow : Dead loop or recursion is too deep , The reason for recursion , It may be too big , It may not end .

* In a function call , The stack will be pressed in order : parameter , Return address ,EBP. If the function has local variables , next , The corresponding space is opened in the stack to construct variables .
* Examples are as follows :
So what is the stack ? If the computer is a white-collar , So the stack is his desk . In order to complete the boss ( program ) Work to account for , This white-collar needs to take out data from the bookshelf or cabinet to check and process . The so-called stack overflow is to solve a task , There's too much information or too much temporary data to process, and the table is full , Then the white-collar went on strike ....

But generally , This desk is big enough , So stack overflow is usually the boss ( program ) There was a problem with the work of the account . The most common is infinite recursion , For example, to solve problems A, The problem must be solved first B, To solve the problem B, The problem has to be solved A, At this time, this white-collar keeps writing notes to solve the problem A, When you're halfway through, you have to take notes to solve the problem B, I still have to write notes to solve the problem A, So repeatedly , Soon the table was filled with notes ( Overflow ).

* usually 「 stack overflow 」 It means 「 call Stack (call
stack) Overflow of 」. It can be difficult to interpret the call stack in a popular way , Because it involves a lot of other computer architecture knowledge . The answer is simply to explain the characteristics of the stack data structure ── First in, second out / Last in, first out . Overflow refers to the overflow of this data structure , Can't store more data . Other data structures also encounter this situation . Even if the data structure is not fixed capacity , It's scalable , In the limited memory space, there is still a chance of overflow .

in addition , A lot of times ,「 Call stack overflow 」 The emergence of is and recursion (recursion) dependent . We can change some recursive implementations to iterations (iteration), But sometimes you have to have a custom stack data structure , For example, depth first search of trees (Depth-First
Search, DFS). The custom stack may overflow .

therefore , Although a stack overflow is often referred to as a call stack overflow , But in essence, it is just a kind of overflow of data structure .

©2019-2020 Toolsou All rights reserved,
Python Garbage collection and memory leak hive Summary of processing methods for a large number of small files The difference between memory overflow and memory leak , Causes and Solutions Create data mysql Library process You don't know ——HarmonyOS stay Vue Use in Web WorkerSparkSQL Achieve partition overlay write msf Generate Trojan horse attack android mobile phone Linux Page replacement algorithm C Language implementation Django Personal blog building tutorial --- Time classified archiving