当前位置:网站首页>Parameter stack pressing problem of C language in structure parameter transmission
Parameter stack pressing problem of C language in structure parameter transmission
2022-04-23 14:25:00 【KissKernel】
First, in memory , It is divided into three areas , The stack area , Heap area , And static area . Local variables are stored in the stack area , Shape parameter , And the space opened up by function calls . Heap area is mainly about dynamic memory allocation . The static area is mainly used to store global variables and static variables .
The problem of parameter stack pressing is put forward in the place of structure parameter transmission ,c When a function passes parameters in a language , Parameters need to be stacked . If you pass a structure object, the structure is too large , The system overhead of parameter stack pressing is too high , Performance will decline . It involves the creation and destruction of function stack frames .
The following reference takes simple code as an example
#include<stdio.h>
int add(int x, int y)
{
int z = 0;
z = x + y;
return z;
}
int main()
{
int a = 20, b = 10;
int ret = 0;
ret = add(a, b);
return 0;
}
The code is abstracted in memory as shown in the figure
b Pass the reference to y It is equivalent to copying a copy in the stack area b.c It's the same thing . This is just passing a variable to the function , If b Become a structure , Because the structure is too large, it will consume too much memory in the stack area , Performance degradation . We usually use the method of address transmission .
版权声明
本文为[KissKernel]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231412252056.html
边栏推荐
- Man man notes and @ reboot usage of crontab
- 基础正则表达式
- 1分钟看懂执行流程,永久掌握for循环(附for循环案例)
- C语言知识点精细详解——数据类型和变量【2】——整型变量与常量【1】
- 一篇博客让你学会在vscode上编写markdown
- Design of single chip microcomputer Proteus for temperature and humidity monitoring and alarm system of SHT11 sensor (with simulation + paper + program, etc.)
- js 抛物线运动方法封装
- JS key value judgment
- LLVM - 生成局部变量
- Uni app message push
猜你喜欢
顺序栈的基本操作
Notes on Visio drawing topology
API gateway / API gateway (IV) - use of Kong - Integrated JWT and fuse plug-in
本以为能躺着进华为,结果陆续收到京东/滴滴/爱奇艺offer的我迷茫了
LM317的直流可调稳压电源Multisim仿真设计(附仿真+论文+参考资料)
redis的五种数据类型
Detailed explanation of SAR command
API Gateway/API 网关(二) - Kong的使用 - 负载均衡Loadbalance
Qt实战:云曦日历篇
关于在vs中使用scanf不安全的问题
随机推荐
MySQL同步Could not find first log file name in binary log index file错误
Debug on TV screen
API gateway / API gateway (IV) - use of Kong - Integrated JWT and fuse plug-in
51 Single Chip Microcomputer Design of traffic light system (with Proteus simulation, C program, schematic diagram, PCB, thesis and other complete data)
Logical volume creation and expansion
错误:无法远程查找到密钥 “428F7ECC7117F726“
LotusDB 设计与实现—1 基本概念
DS1302的电子万年历_51单片机,年月日、星期、时分秒、农历和温度,带闹钟,全套资料
Redis cluster 原理
Returns the subscript after array sorting
ansible及常用模块的使用
C语言知识点精细详解——数据类型和变量【2】——整型变量与常量【1】
初始c语言大致框架适合复习和初步认识
Golang 对分片 append 是否会共享数据
Detailed explanation of SAR command
LLVM - 生成for循环
Uni app message push
flannel 原理 之 TUN模式
After entering the new company, the operation and maintenance engineer can understand the deployment of the system from the following items
Docker篇 (五) MySQL的安装