免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 11945 | 回复: 6
打印 上一主题 下一主题

如何删除共享内存 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2006-05-12 12:56 |只看该作者 |倒序浏览
如何删除共享内存?

我现在只知道建立一个共享内存,也会用ipcs去查看,但如何删除呢?

论坛徽章:
0
2 [报告]
发表于 2006-05-12 13:10 |只看该作者
ipcrm
man shmctl

论坛徽章:
0
3 [报告]
发表于 2006-05-12 14:16 |只看该作者

回复 1楼 lee_scs 的帖子

The shmctl (“SHared Memory ConTroL”) call returns information about a shared
memory segment and can modify it.The first parameter is a shared memory segment
identifier.
   To obtain information about a shared memory segment, pass IPC_STAT as the
second argument and a pointer to a struct shmid_ds.
   To remove a segment, pass IPC_RMID as the second argument, and pass NULL as the
third argument.The segment is removed when the last process that has attached it
finally detaches it.
   Each shared memory segment should be explicitly deallocated using shmctl when
you’re finished with it, to avoid violating the systemwide limit on the total number of
shared memory segments. Invoking exit and exec detaches memory segments but
does not deallocate them.

这个够详细了把。

论坛徽章:
0
4 [报告]
发表于 2006-05-12 14:48 |只看该作者
不好意思,弱弱地问一下

shmctl 是程序里写的吧。

ipcrm后面跟什么参数?是不是shmid

删除共享内存是把这段内存释放出来可供其它程序用?还是把里面的内容都删掉

论坛徽章:
0
5 [报告]
发表于 2006-05-12 14:54 |只看该作者
原帖由 lee_scs 于 2006-5-12 14:48 发表
不好意思,弱弱地问一下

shmctl 是程序里写的吧。

ipcrm后面跟什么参数?是不是shmid

删除共享内存是把这段内存释放出来可供其它程序用?还是把里面的内容都删掉

man ipcrm

论坛徽章:
0
6 [报告]
发表于 2006-05-12 15:05 |只看该作者
/* 初始化共享内存 */
   key=0x00111111;
   shmid=shmget(key,1024,0666);
   shmctl(shmid,IPC_RMID,0);

论坛徽章:
0
7 [报告]
发表于 2006-05-12 22:07 |只看该作者
昏倒, 几乎无语
先ipcs -m 看看那些shmid该删
然后ipcrm -m shmid
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP