当前位置:网站首页>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
边栏推荐
- js 递归(1)
- 基于TLC5615的多路可调数控直流稳压电源,51单片机,含Proteus仿真和C代码等
- After entering the new company, the operation and maintenance engineer can understand the deployment of the system from the following items
- API Gateway/API 网关(四) - Kong的使用 - 集成Jwt和熔断插件
- Man man notes and @ reboot usage of crontab
- 差分隐私(背景介绍)
- 关于UDP接收icmp端口不可达(port unreachable)
- x509证书cer格式转pem格式
- 交通灯系统51单片机设计(附Proteus仿真、C程序、原理图及PCB、论文等全套资料)
- Matlab Simulink modeling and design of single-phase AC-AC frequency converter, with MATLAB simulation, PPT and papers
猜你喜欢
流程控制之分支语句
常见存储类型和FTP主被动模式解析
Nacos uses demo as configuration center (IV)
Design of single chip microcomputer Proteus for temperature and humidity monitoring and alarm system of SHT11 sensor (with simulation + paper + program, etc.)
C语言知识点精细详解——数据类型和变量【1】——进位计数制
A table splitting implementation scheme of MySQL and InnoDB, MyISAM and MRG_ Introduction to MyISAM and other engine application scenarios
剑指offer刷题(2)--面向华为
顺序栈的基本操作
man man随记和crontab的@reboot用法
AT89C52单片机的频率计(1HZ~20MHZ)设计,LCD1602显示,含仿真、原理图、PCB与代码等
随机推荐
asp.net使用MailMessage发送邮件的方法
js 抛物线运动方法封装
Debug on TV screen
JS recursion (1)
金九银十,入职字节跳动那一天,我哭了(蘑菇街被裁,奋战7个月拿下offer)
Detailed explanation of SAR command
LLVM - 生成加法
API gateway / API gateway (IV) - use of Kong - Integrated JWT and fuse plug-in
字节面试编程题:最小的K个数
操作系统常见面试题目:
Arrays类的使用案例
Logical volume creation and expansion
kprobe 的 3 种使用
Nacos作为配置中心(四) 使用Demo
C语言知识点精细详解——数据类型和变量【1】——进位计数制
交通灯系统51单片机设计(附Proteus仿真、C程序、原理图及PCB、论文等全套资料)
MySQL基础知识
翻牌效果
顺序栈的基本操作
关于在vs中使用scanf不安全的问题