当前位置:网站首页>[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
边栏推荐
- 网络通讯之Socket-Tcp(一)
- Unity3d learning notes 5 - create sub mesh
- [learning notes] DP status and transfer
- Simple factory and factory method mode
- Dart: about grpc (I)
- SystemVerilog -- OOP -- copy of object
- Socket TCP for network communication (I)
- JVM内存模型
- Display time with message interval of more than 1 minute in wechat applet discussion area
- Shutter: add gradient stroke to font
猜你喜欢
【附下载】密码获取工具LaZagne安装及使用
Integer int compare size
QT OpenGL texture map
CGroup introduction
Shutter: overview of shutter architecture (excerpt)
Download address and installation tutorial of vs2015
Unicode encoding table download
Kubernetes three dozen probes and probe mode
[learning notes] DP status and transfer
Qt+vtk+occt reading iges/step model
随机推荐
[MySQL special] read lock and write lock
Download address and installation tutorial of vs2015
ArcGIS application (XXI) ArcMap method of deleting layer specified features
Redis 笔记 01:入门篇
SystemVerilog -- OOP -- copy of object
(构造笔记)GRASP学习心得
OpenGL 着色器使用
Prompt unread messages and quantity before opening chat group
为什么我的mysql容器启动不了呢
If you can't learn, you have to learn. Jetpack compose writes an im app (I)
Itext7 uses iexternalsignature container for signature and signature verification
257. All paths of binary tree
Adult adult adult
DEJA_VU3D - Cesium功能集 之 053-地下模式效果
Adult adult adult
(构造笔记)ADT与OOP
Redis
4000字超详解指针
使用BLoC 构建 Flutter的页面实例
laravel 时区问题timezone