当前位置:网站首页>malloc 和 空間配置器
malloc 和 空間配置器
2022-07-22 01:16:00 【Diligent_wu】
malloc的原理:
1.malloc開始搜索空閑空間,如果能找到一塊合適的空間就分配出去
2.找不到就調用系統調用brk從堆區獲取更多的空閑空間(以128為界限,brk或mmap)
3.調用brk後轉入內核態,此時虛擬地址系統開始工作,擴大進程的堆區(並沒有分配更多的物理內存)
4.brk完成之後返回到malloc,malloc找到合適的空間之後返回(內核態切換到用戶態)
5.進程拿到資源,繼續幹活
6.當有代碼讀寫新申請的內存內部出現缺頁中斷,此時由用戶態切換到內核態,操作系統此時分配物理內存,再切換回去,程序繼續。
空間配置器
STL-SGI使用兩級空間配置器保證堆區資源的合理應用,超過128types的使用以及空間配置器,低於128字節的使用二級空間配置器,下面就是二級空間配置器的具體分配流程
边栏推荐
- DOM -- style operation
- & lt; A & gt; Étiquette pour passer à la page serveur et passer les paramètres
- IP 地址段分类
- uniapp 微信小程序 用户授权 获取用户信息
- 关于 Object obj = new Object()
- 1306_两个开源printf的资源使用对比测试
- Difference between two lists
- Diversified system to carry out maker education activities
- Leetcode [剑指 Offer II 068. 查找插入位置
- About object obj = new object()
猜你喜欢
Web自动化处理“滑动验证码”
Technology sharing | introduction to proxysql binlog reader component (Part 1)
解读符合新时代主流的创客教育模式
LeetCode刷题:二叉树层序遍历相关题目
Lihua Fast food ordering applet
Installation du gestionnaire de loisirs
IP address segment classification
[rm_ee_note] 1 gm6020 transceiver & simple PID debugging
Openshift 4 - configure openshift cluster logging environment
Unity learning notes - Hot update related
随机推荐
TCP/IP协议栈Lwip的设计与实现:之六
TCP/IP协议栈Lwip的设计与实现:之七
Analysis of steam education benefiting primary and secondary schools
The Sandbox 联手 Agoria,共同打造 Agoriaverse
visual studio引用外部庫的注意事項
06. Introduction, installation and simple use of octave
"Can't buy" digital transformation, each family's "LEGO" is different
Time insertion syntax of Oracle table
通过例子学C标准库<ctype.h>
[data analysis 01]
Websocket transfer file
dom——预加载和懒加载
Halcon and opencv finally chose the latter
Solve the problem that the uploaded file of ftpclient is empty and 0 bytes are displayed
MQTT5.0新特性(比对3.1.1)
类模板重载输出运算符报错
Verilog: bitwise, logical
ITK median filter
Precautions for visual studio to reference external libraries
【SemiDrive源码分析】【模块BringUp】37 - LCM 驱动 Bringup 流程