Joke Collection Website - Mood Talk - C language knowledge: Talk about the differences between the following statements
C language knowledge: Talk about the differences between the following statements
The following explains the three ways in which C language is related to memory allocation:
(1) Allocate from static storage area. Memory is allocated when the program is compiled, and this memory exists throughout the entire runtime of the program. For example, global variables and static variables.
(2) Created on the stack. When executing a function, the storage units for local variables within the function can be created on the stack. These storage units are automatically released when the function is executed, following the first-in, last-out principle. The stack memory allocation operation is built into the processor's instruction set and is very efficient, but the allocated memory capacity is limited. This method does not produce memory fragmentation, and programmers do not need to intervene in memory allocation.
(3) Allocation from the heap, also known as dynamic memory allocation. When the program is running, you can use malloc or new to apply for any amount of memory. The programmer is responsible for when to use free or delete to release the memory. The dynamic memory allocation method requires programmer intervention and will produce memory fragmentation. Its lifetime is determined by us. It is very flexible to use, but it also has the most problems.
- Previous article:The use of teacher qualification certificate
- Next article:Send pictures of friends circle on Valentine's Day.
- Related articles
- Tell me about the little classmate who can read.
- Du's Crystal Lyrics
- Parameter configuration of 3s 55-inch millet TV (which model has the highest cost performance and its evaluation)
- A collection of young sentences that you can't go back (50)
- What quotations are there that are unnecessary to maintain a relationship?
- How to make a delicious and simple cake video
- Sentences describing smiles
- Which two poems are to persuade people to eat, drink and be merry in time?
- How to use qq housekeeper to move by software
- How to match the video of eating in kindergarten with words