子进程中的内存泄漏怎么办

发布于 2024-10-05 01:43:40 字数 148 浏览 0 评论 0原文

我在unix平台上。

存在 memleak 的进程的内存会在进程终止时被清理。

如果一个进程已经产生了一个子进程,而该子进程存在内存泄漏,那么情况又如何呢? 子进程终止时泄漏的内存会被清除吗?或者这个内存现在会保留在父进程中吗?

谢谢

Im on unix platform.

The memory of a process with a memleak is cleaned at process termination.

What about a process, that has spawned a child, where the child has a memleak.
Will the leaked memory be cleaned up at childprocess termination? Or will this memory now stick with the parent process.

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

梦魇绽荼蘼 2024-10-12 01:43:40

子进程分配的内存仅存在于子进程的虚拟地址空间中,而不存在于父进程的虚拟地址空间中。一旦子进程终止或通过 exec 系列函数之一将其自身替换为新的程序映像,它将被释放。

这与线程形成对比,线程共享公共虚拟地址空间,并且在新线程中进行的分配将在线程退出后持续存在并仍然可供其他线程使用。

The memory allocated by the child process exists only in the child process's virtual address space, not the parent's. It will be freed as soon as the child process terminates or replaces itself with a new program image via one of the exec family of functions.

This is in contrast to threads, which share a common virtual address space, and where allocations made in a new thread will persist after the thread exits and remain usable by other threads.

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