当前位置:网站首页>[embedded] - Introduction to four memory areas
[embedded] - Introduction to four memory areas
2022-07-03 12:20:00 【EVA】
One 、 Origin of four memory areas
Program execution runs in memory , And different objects in the program ( Such as The pointer , local variable , Global variables , Function parameter wait ) The required life cycle is different , So put these objects in different sections , This gives these objects different lifecycles , Four memory areas come from this .
Two 、 Introduction to four memory areas
Memory four is divided into : The stack area , Heap area , Global area , Code section .
1. The stack area (stack)
Stack area is automatically allocated and released by compiler .
The stack area mainly stores function parameters 、 Function return value 、 local variable .
2. Heap area (heap)
Heap area is manually allocated and released by programmer . If the programmer does not release , At the end of the program , Released by the system .
The stacking area is mainly stored by malloc Keyword applied memory space . stay C++ Keywords in language new The requested memory is also in the heap .
3. Global area
The global area is also called data area or static area .
The overall situation is divided into three segments : data paragraph 、bss paragraph 、rodata paragraph .
(1).data Segment storage has been initialized and the value is not 0 And static variables
(2).bss The segment storage is uninitialized and the initialization value is 0 And static variables .
(3).rodata Segments store various constants , Such as :const、 character string 、#define etc.
data Duan also called RW-data paragraph
bss Duan also called ZI-data paragraph
rodata Segments are also called constant areas or read-only storage areas
4. Code section (text)
Code area is also called code paragraph or text paragraph .
Used to store program code , Managed by the operating system , read-only .
3、 ... and 、 Add extra
flash perhaps ROM The data is still saved after power failure , The saved data are RO-data、RW-data、 Code section
RAM Generally speaking, it means sdram, Fast running speed , But the power down data will be lost , The saved data are The stack area 、 Heap area 、 Data area
Be careful :
1,flash perhaps ROM Why not save ZI-data?
ZI-data Segment data is not initialized or initialized to 0, When starting the system, directly put this flash perhaps ROM clear 0 that will do , No need to save .
2,RW-data yes RAM The use of , Why store to flash or ROM in ?
RW-data This part of the variable has been initialized , There is only RAM Power loss will result in loss , So you need to be in flash or ROM Store a copy of
边栏推荐
猜你喜欢

Shardingsphere sub database and sub table < 3 >

OPenGL 基本知识(根据自己理解整理)

Unicode encoding table download

If you can't learn, you have to learn. Jetpack compose writes an im app (II)

laravel 时区问题timezone

OpenGL draws colored triangles

2.7 overview of livedata knowledge points

4000 word super detailed pointer

(构造笔记)ADT与OOP

Qt OpenGL 纹理贴图
随机推荐
1-1 token
Vulnhub's Nagini
20. Valid brackets
[combinatorics] permutation and combination (summary of permutation and combination content | selection problem | set permutation | set combination)
Dart: About zone
DNS multi-point deployment IP anycast+bgp actual combat analysis
Vulnhub pyexp
Why can't my MySQL container start
网络通讯之Socket-Tcp(一)
OpenGL 绘制彩色的三角形
Flutter: self study system
Shutter widget: centerslice attribute
MySQL time zone solution
[MySQL special] read lock and write lock
PHP export word method (one MHT)
Solution à la défaillance de l'installation d'Electron
网上炒股开户安不安全?谁给回答一下
How to convert a numeric string to an integer
typeScript
Talk about the state management mechanism in Flink framework