当前位置:网站首页>Shared memory - shmget filling holes
Shared memory - shmget filling holes
2022-07-29 14:23:00 【A corner of peace, occupying the mountain as the king】
shmget设置的size值,不能大于最大值SHMMAXand is less than the minimum valueSHMMIN
且若是keyThe segment corresponding to the value already exists,Then use it latershmget的sizeThe value must be less than or equal to the original value function
Then I asked the programmer,He set20kB,个人是100kB,And his settings are to start at boot,So it was me who made the mistake every time,悲催!
/******************************************************************************
*函数名称:yg_init_mem_share
*功能描述: 初始化共享内存(Used to store map calibration data)
*全局影响:无
*输入:
*输出:无
*返回值:0:成功 -1:发送失败
* 做者 日期 内容
* Jimmy 2018-10-16 建立
*
******************************************************************************/
void yg_init_mem_share(int size)
{
key_t key;
//int size = 1024*1024; //1M内存大小
//1. 建立共享内存
if(-1 == (key = ftok("/", 4)))
{
bv_loge("ftok failed [%d:%s]!", errno, strerror(errno));
bv_error_handle("ftok failed [%d:%s]!", errno, strerror(errno));
return ;
}
bv_logd("key=%#x!", key);
SHM_ID = shmget(key, (size_t)size, IPC_CREAT|0644);
if(-1 == SHM_ID)
{
bv_loge("Init the shared memory[%dKB] failed [%d:%s]!",size/1024, errno, strerror(errno));
bv_error_handle("Init the shared memory[%dKB] failed [%d:%s]!",size/1024, errno, strerror(errno));
}
else
{
bv_logd("Init the shared memory[%dKB] OK!", size/1000);
bv_file_log(g_tcp_fp, "Init the shared memory[%dKB] OK!", size/1000);
}
return ;
}The above is copied from others,意思就是说,你先创建了一个KEY对应的文件,比如说是K1,现在程序运行时K1对应的内存SIZE是1000字节,Later you want to expand this memory,Modify the allocated memory directly,最大还是1000字节,只有删掉K1对应的文件,Recreate and allocate larger memory,才能满足.
边栏推荐
- 国内helm快速安装和添加常用charts仓库
- How to return all prime factors of a number?
- AI全流程开发难题破解之钥
- 【FreeSwitch开发实践】自定义模块创建与使用
- 根据msql表的结构自动生成gorm的struct
- The Advanced Guide to the Computer Professional Interview
- 2022年七夕情人节有什么值得推荐的礼物选择?实用且高级礼物推荐
- Network connection optimization for instant messaging mobile terminal development
- What is the difference between the legendary server GOM engine and the GEE engine?
- TCP流量控制和拥塞控制
猜你喜欢
随机推荐
【10点公开课】:快手GPU/FPGA/ASIC异构平台的应用探索
基于变胞机构的移动机器人构型设计研究综述
84.(cesium之家)cesium模型在地形上运动
性能优化竟白屏,难道真是我的锅?
How to merge the code when there is a code conflict in the collaborative development of multiple people?
何为擦除机制,泛型的上界?
PytestFixture实战应用+Pytest.ini与conftest.py应用详解+Fixture及yield实现用例前置后置
[局域网劫持]如何搞懵蹭网的同学-详细过程
human pose estimation-DEKR2021CVPR
接口和抽象
程序员是职业病高发群体,别天真的以为只有秃头那么简单,才不是呢。
已解决SyntaxError: invalid character in identifier
国产手机将用户变成它们的广告肉鸡,难怪消费者都买iPhone了
zabbix一键部署脚本----亲测可用
项目经理:不错啊!SSO单点登录代码写出来了,把时序图也画一下?
全开放式耳机怎么样?不塞耳朵的蓝牙耳机推荐
第二轮Okaleido Tiger热卖的背后,是背后生态机构战略支持
城市污水处理过程模型预测控制研究综述
新来技术总监:谁在用 isXxx 形式定义布尔类型,明天不用来了!
使用云服务器从0开始搭建云端Jupyter Lab|Notebook








