当前位置:网站首页>内存池原理一(基于整块)
内存池原理一(基于整块)
2022-06-10 17:15:00 【QQ851301776】
创作人QQ:851301776,邮箱:[email protected],欢迎大家一起技术交流,本博客主要是自己学习的心得体会,只为每天进步一点点!
个人座右铭:
1.没有横空出世,只要厚积一定发。
2.你可以学历不高,你可以不上学,但你不能不学习
一、内存池设计思路
1.内存池解决的问题(malloc/free)
(1)不利于内存管理
(2)内存碎片厉害
(3)程序容易出现内存泄漏,最终产生内存溢出
2.内存池设计的做法(4K)
(1)伙伴算法
分配:把4K,按照2的n次方的方式,从0开始分配成:1/2/4/8/16/32/64/128/256/512/1K/2K这些块,核心思维:把整块变成散块
使用:比如需要129个字节:就会把256这个块再次拆分成:128/64/32/16/8/4/2/1,
合并:把相邻相同大小的两块合并起来,和下一块放到一起。需要第一个条件两块相邻,第二个条件两块必须一样大。
释放:把小块变大块,统一释放
(2)slab
这里不解释,可以查看nginx使用slab的内存池部分(slab核心是把:比如一个4K的页,全部变成4/8/16(数字只是举例), 这种小块)
边栏推荐
- 领导提拔你的原因,只有这点最真实,其他都是瞎扯!
- Nacos registry
- High number_ Chapter 6 infinite series__ Absolute convergence_ Conditional convergence
- well! One new star, please look over | elder martial brother and elder martial sister say
- Importerror: libgl. so. 1: cannot open shared object file: no such file or directory
- 基于PHP+Web+Mysql的在线问卷调查系统
- 牛客网:两数之和
- Jouer avec la classe de fonctions de pytorch
- if else的使用太简单?(看懂这篇你的逻辑会进一步提升)
- Play with pytoch's function class
猜你喜欢

“挽弓当挽强,用箭当用长”,曼孚科技为数据服务行业开启新赛道

Classic topics of leetcode tree (I)

Leetcode 875. Coco, who likes bananas

聊聊消息中间件(1),AMQP那些事儿

C#_ Serial port communication project

mmdetection之dataloader构建

pands pd. Detailed parsing of dataframe() function

【AXI】解读AXI协议双向握手机制的原理

canvas发散的粒子h5动画js特效

Numpy np set_ Usage of printoptions () -- control output mode
随机推荐
The short ticket hypothesis: finding sparse, trainable neural networks
MMdetection之build_optimizer模块解读
使用Canvas实现的噪音线条h5js特效
LeetCode 321. 拼接最大數***
LeetCode 255. 验证前序遍历序列二叉搜索树*
《华为数据之道》读书笔记
仅需三步学会使用低代码ThingJS与森数据DIX数据对接
[the second revolution of report tools] optimize report structure and improve report operation performance based on SPL language
安全感
Leetcode String to integer(Atoi)
CUDA实现高效查找--审核未通过?
Nacos registry
李飞飞:我更像物理学界的科学家,而不是工程师|深度学习崛起十年
Jouer avec la classe de fonctions de pytorch
力扣 20. 有效的括号
AI 加持实时互动|ZegoAvatar 面部表情随动技术解析
How will you integrate into the $20trillion "project economy" in five years
ZigBee模块无线传输星形拓扑组网结构简介
pands pd. Detailed parsing of dataframe() function
Redis general instruction