不分离共享内存段会产生什么影响

发布于 2024-07-24 05:04:09 字数 125 浏览 2 评论 0原文

  • 不分离共享内存段有什么影响?

  • 不同的操作系统如何处理这个问题?

  • 不分离会影响操作系统的稳定性吗?

谢谢。

  • 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

老子叫无熙 2024-07-31 05:04:09

如果共享内存段未分离,则内核会继续认为特定段(内核称为区域)正在使用中,并且永远不会将其标记为删除 - 内部使用一种引用计数机制。 另一个问题是进程的虚拟地址空间会被不必要地耗尽。

然而,我不确定我们是否可以称之为内存泄漏(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.

影子是时光的心 2024-07-31 05:04:09

不分离会阻止其他人删除该内存段,在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 ?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文