当前位置:网站首页>[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
边栏推荐
- Prompt unread messages and quantity before opening chat group
- 抓包整理外篇fiddler———— 会话栏与过滤器[二]
- Shutter: add gradient stroke to font
- 2020-10_ Development experience set
- Unicode encoding table download
- OPenGL 基本知识(根据自己理解整理)
- shardingSphere分库分表<3>
- 2.9 overview of databinding knowledge points
- Integer string int mutual conversion
- 使用BLoC 构建 Flutter的页面实例
猜你喜欢

Quantitative calculation research

Shardingsphere sub database and sub table < 3 >

Introduction to the implementation principle of rxjs observable filter operator

Summary of development issues

Unicode encoding table download

OpenGL 索引缓存对象EBO和线宽模式

PHP导出word方法(一mht)

Qt+vtk+occt reading iges/step model

【mysql专项】读锁和写锁

Laravel time zone timezone
随机推荐
How to convert a numeric string to an integer
(构造笔记)从类、API、框架三个层面学习如何设计可复用软件实体的具体技术
(構造筆記)從類、API、框架三個層面學習如何設計可複用軟件實體的具體技術
If you can't learn, you have to learn. Jetpack compose writes an im app (I)
Solution à la défaillance de l'installation d'Electron
Simple factory and factory method mode
temp
Jsup crawls Baidu Encyclopedia
PHP get the file list and folder list under the folder
AOSP ~ NTP (Network Time Protocol)
PHP導出word方法(一mht)
Apprendre à concevoir des entités logicielles réutilisables à partir de la classe, de l'API et du cadre
2020-10_ Development experience set
Unicode查询的官方网站
Redis notes 01: Introduction
Flutter: self study system
DEJA_VU3D - Cesium功能集 之 054-模拟火箭发射全过程
实现验证码验证
Develop plug-ins for idea
网络通讯之Socket-Tcp(一)