C++ shared memory leak, how to clear shared memory?
来源:互联网 发布:戒断反应 戒烟 知乎 编辑:程序博客网 时间:2024/05/17 22:59
http://stackoverflow.com/questions/7773276/c-shared-memory-leak-how-to-clear-shared-memory
You could always run a script after termination of your program to manually clear the shared memory, semaphores, etc. on your system (mine is a Mac Pro running 10.8). I have inserted a script I use for this when running programs that use QSharedMemory, and use it when the program quits unexpectedly and leaves the shared memory instances "hanging".
Keep in mind this will remove all shared memory instances associated with your user name. If you have multiple programs running and using shared memory instances, you should either wait until every program is done, or adjust the script as needed to only delete the shared memory instances that were created by your program.
#!/bin/bashME=$(whoami)IPCS_S=$(ipcs -s | grep $ME | sed "s/ / /g" | cut -f2 -d " ")IPCS_M=$(ipcs -m | grep $ME | sed "s/ / /g" | cut -f2 -d " ")IPCS_Q=$(ipcs -q | grep $ME | sed "s/ / /g" | cut -f2 -d " ")echo "Clearing Semaphores"for id in $IPCS_Sdo ipcrm -s $iddoneecho "Clearing Shared Memory"for id in $IPCS_M do ipcrm -m $iddoneecho "Clearing Message Queues"for id in $IPCS_Qdo ipcrm -q $iddone
- C++ shared memory leak, how to clear shared memory?
- shared memory
- Shared memory
- Shared Memory
- [C/C++] Shared memory access
- how to debug memory-leak
- How to Find A Memory Leak
- How to list processes attached to a shared memory segment in linux?
- Linux IPC - Shared memory
- What is Shared Memory?
- [PHP] Shared memory access
- postgresql的shared memory
- Modifying Shared Memory
- Shared Memory Example
- CUDA shared memory
- informix Shared memory 错误
- Unix Shared Memory
- shared memory driver(1)
- 做好网站优化的投票排名算法
- scrollView中edittext抢焦点问题
- SP2010开发和VS2010专家"食谱"--第七章节--使用客户端对象模型(2)--Handling exceptions
- C#实时zip压缩和解压移动设备版Xceed Real-Time Zip for .NET CF下载及详细介绍
- 用minGW编译ffmpeg(供替换opencv中引用的ffmpeg库)
- C++ shared memory leak, how to clear shared memory?
- 网站健康成长的关键—网站饱和度
- 使用 Spring jdbcTemplate 进一步简化 JDBC 操作
- ffmpeg 编译静态库,搞了好久,终于搞成功了,中间搞得烦死了,根据网上教程做的
- python初学者注意版本
- 【割点】
- Unity Avatar动画系统
- PHP上传限制
- leetcode Unique Paths & Unique Paths II & Minimum Path Sum