当前位置:网站首页>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,才能满足.
边栏推荐
猜你喜欢

iMedicalLIS监听程序(1)

Network connection optimization for instant messaging mobile terminal development

多人协作开发出现代码冲突,如何合并代码?

How to merge the code when there is a code conflict in the collaborative development of multiple people?

新来技术总监:谁在用 isXxx 形式定义布尔类型,明天不用来了!

开放式耳机推荐哪款最好最实用、最好的开放式耳机推荐

2022年了!还在用定时器实现动画?赶紧试试requestAnimationFrame吧!

kubernetes cks strace etcd

Sentinel vs Hystrix 限流到底怎么选?(荣耀典藏版)

熊市下PLATO如何通过Elephant Swap,获得溢价收益?
随机推荐
iMedicalLIS监听程序(1)
Sentinel vs Hystrix 限流到底怎么选?(荣耀典藏版)
第二轮Okaleido Tiger热卖的背后,是背后生态机构战略支持
熊市下PLATO如何通过Elephant Swap,获得溢价收益?
抓住这几个关键点,做薪酬数据分析并不难
潘多拉 IOT 开发板学习(RT-Thread)—— 实验19 MQTT 协议通信实验(学习笔记)
Nine kinds of way, teach you to read the resources files in the directory path
human pose estimation-DEKR2021CVPR
企业需要知道的5个 IAM 最佳实践
马尔可夫跳变线性系统最优控制的研究现状与进展
国内helm快速安装和添加常用charts仓库
有关包装类的一道经典面试题
一文搞懂JS的原型链
线上支付,出款和收款
性能优化竟白屏,难道真是我的锅?
The Advanced Guide to the Computer Professional Interview
已解决SyntaxError: invalid character in identifier
全开放式耳机怎么样?不塞耳朵的蓝牙耳机推荐
系列文章|云原生时代下微服务架构进阶之路 - Boris
解决:Parameter 0 of method ribbonServerList in com.alibaba.cloud.nacos.ribbon.NacosRibbonClientConfigu