当前位置:网站首页>[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
边栏推荐
- 抓包整理外篇fiddler———— 会话栏与过滤器[二]
- lambda与匿名内部类的区别
- Dart: about grpc (I)
- (构造笔记)GRASP学习心得
- 网络通讯之Socket-Tcp(一)
- DNS multi-point deployment IP anycast+bgp actual combat analysis
- How to deploy web pages to Alibaba cloud
- Interview experience in summer camp of Central South University in 2022
- 20. Valid brackets
- Self made pop-up input box, input text, and click to complete the event.
猜你喜欢

ES6 standard

Shutter widget: centerslice attribute

Wrong arrangement (lottery, email)

4000 word super detailed pointer

OpenGL draws colored triangles

Visual studio 2022 downloading and configuring opencv4.5.5

Php Export word method (One MHT)

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

Flutter 退出登录二次确认怎么做才更优雅?

QT OpenGL texture map
随机推荐
Dart: view the dill compiled code file
laravel 时区问题timezone
2.8 overview of ViewModel knowledge
DNS multi-point deployment IP anycast+bgp actual combat analysis
257. All paths of binary tree
Optimize interface performance
Summary of development issues
Qt+vtk+occt reading iges/step model
Introduction to concurrent programming (I)
1-1 token
Slf4j log facade
【嵌入式】---- 内存四区介绍
lambda与匿名内部类的区别
win10 上PHP artisan storage:link 出现 symlink (): Protocol error的解决办法
Capturing and sorting out external Fiddler -- Conversation bar and filter [2]
Interview experience in summer camp of Central South University in 2022
实现验证码验证
Display time with message interval of more than 1 minute in wechat applet discussion area
Symlink(): solution to protocol error in PHP artisan storage:link on win10
Integer string int mutual conversion