不分离共享内存段会产生什么影响
不分离共享内存段有什么影响?
不同的操作系统如何处理这个问题?
不分离会影响操作系统的稳定性吗?
谢谢。
What are the effects of not detaching a Shared Memory Segment?
How different operating systems handle this?
Can not detaching compromise the stability of the O.S?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果共享内存段未分离,则内核会继续认为特定段(内核称为区域)正在使用中,并且永远不会将其标记为删除 - 内部使用一种引用计数机制。 另一个问题是进程的虚拟地址空间会被不必要地耗尽。
然而,我不确定我们是否可以称之为内存泄漏(Java 人会说),因为这个内存段会在进程退出时自动分离和释放。
这可能不会损害整个操作系统,但系统可能必须关闭 - 这也是在没有任何通知的情况下 - 一些进程在内存不足时占用大量内存(请参阅 Linux OOM Killer)。 但这是最坏的情况。
If shared memory segment is not detached then the kernel keeps on thinking that the particular segment (kernel call it region) is in use and would never mark it for deletion - kind of reference counting mechanism is used internally. Another problem, would be that process' virtual address space would be eaten up unnecessarily.
However, I am not sure if we can call it memory leak (Java people would say, although) because this memory segment would be detached and freed automatically the moment process exits.
This may not compromise OS as a whole, but system may have to close - that too without any notice - some processes that are eating a huge memory if it goes out of memory( See Linux OOM killer). But this is the worst case.
不分离会阻止其他人删除该内存段,在windows和linux上都是如此。 因此你会出现内存泄漏。 它不会损害操作系统的稳定性,但为什么您不想在使用完该段后分离并删除它呢?
Not detaching will prevent others from deleting the memory segment, this is true on windows and on linux. Thus you will have a memory leak. It wont compromise the stability of the O.S but why won't you want to detach and delete the segment once you finish using it ?