当前位置:网站首页>[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
边栏推荐
- init. RC service failed to start
- DEJA_VU3D - Cesium功能集 之 054-模拟火箭发射全过程
- 111. Minimum depth of binary tree
- [combinatorics] permutation and combination (summary of permutation and combination content | selection problem | set permutation | set combination)
- win10 上PHP artisan storage:link 出现 symlink (): Protocol error的解决办法
- Socket TCP for network communication (I)
- Flutter: about monitoring on flutter applications
- Capturing and sorting out external Fiddler -- Conversation bar and filter [2]
- PHP export word method (phpword)
- Flutter Widget : Flow
猜你喜欢
Prompt unread messages and quantity before opening chat group
实现验证码验证
Is BigDecimal safe to calculate the amount? Look at these five pits~~
PHP export word method (one MHT)
Flutter 退出登录二次确认怎么做才更优雅?
[official MySQL document] deadlock
Vulnhub's Tomato (tomato)
Pki/ca and digital certificate
【mysql专项】读锁和写锁
Wechat applet - basic content
随机推荐
Apprendre à concevoir des entités logicielles réutilisables à partir de la classe, de l'API et du cadre
Flutter Widget : Flow
Summary of development issues
Self made pop-up input box, input text, and click to complete the event.
Talk about the state management mechanism in Flink framework
lambda与匿名内部类的区别
为什么我的mysql容器启动不了呢
Fundamentals of concurrent programming (III)
Capturing and sorting out external Fiddler -- Conversation bar and filter [2]
Adult adult adult
Itext7 uses iexternalsignature container for signature and signature verification
MCDF Experiment 1
242. Effective letter heteronyms
在网上炒股开户可以吗?资金安全吗?
Introduction to concurrent programming (I)
PHP導出word方法(一mht)
OpenGL shader use
Develop plug-ins for idea
SystemVerilog -- OOP -- copy of object
[combinatorics] permutation and combination (summary of permutation and combination content | selection problem | set permutation | set combination)