Linux 中的 malloc 挂起

发布于 2024-09-06 05:02:41 字数 305 浏览 11 评论 0原文

我在一台具有 16 G 内存和 2 个四核 CPU 的机器上使用 SUSE 10 Linux。 有 8 个进程正在执行一些工作(CPU 密集型/网络 I/O)。其中 4 个存在内存泄漏(这些是测试条件,因此这里发生泄漏没有问题)。 所有进程占用的总空间约为15.4G,系统中仅200MB可用。 几个小时内一切都很好。但之后 malloc 挂起(对于没有内存泄漏的进程)。 卡住了超过 4 分钟(注意 CPU 不是 100%,但 io 明显上升)。 现在挂起的进程没有问题(它没有损坏内存)。 malloc 在做什么? (它是否试图进行碎片整理或建立交换空间)。

有什么指点吗?

I am using SUSE 10 Linux on a machine with 16 G ram and 2 quad core CPUs.
There are 8 processes which are doing some work (CPU intensive/network i/o). Out of which 4 have a memory leak (These are test conditions so no problem in having leaks here).
Total space is occupied by all processes is around 15.4 G only 200 MB is free in system.
Things are fine for some hours. But after that malloc hangs (for a process which doesn't have a memory leak).
Its stuck for more than 4 minutes (Note CPU is not 100% but io has gone up signficantly).
Now there is no problem in the hanged process (it has not corrupted the memory).
What is malloc doing? (is it trying to defragment or building up swap space).

Any pointers?

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

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

发布评论

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

评论(3

只想待在家 2024-09-13 05:02:44

在你的机器之前,内存的寿命很短。现在你的 malloc 超出了你机器的 16G 限制,你的系统开始交换。
但按照 PierreBdR 的提示检查您的申请无疑是个好主意。

Before you machine was just short on life RAM. Now your malloc goes beyond the 16G limit of your machine and your system starts swapping.
But checking your application as hinted by PierreBdR is certainly a good idea.

心意如水 2024-09-13 05:02:43

这可能很烦人,但我建议在阻塞的进程上使用 Valgrind。可能存在您之前未检测到的错误。至少,您可能知道正在发生什么。然而,这几个小时可能会变成几天:/

It might be annoying, but I would recommend using Valgrind on the process that blocks. There might be errors you didn't detect before. At least, you might have an idea of what is happening. However, the few hours might become days :/

各空 2024-09-13 05:02:41

如果 malloc() 只是花费很长时间,那么您可能正在遍历一个碎片化的空闲列表,其中许多条目已被换出。这与低 CPU、高 IO 和有限的可用 RAM 是一致的。

有关 malloc() 实现的更多信息(包括了解碎片空闲列表),维基百科文章很好:http://en.wikipedia.org/wiki/Malloc#Implementations

哦,内存泄漏是不可接受的,即使在测试环境中也是如此。正如您所看到的,它们会干扰(据您所知)没有泄漏的程序,并浪费您的时间。

If malloc() simply takes a long time, you're probably traversing a fragmented free list, many of whose entries have been swapped out. That is consistent with low CPU, high IO, and limited free RAM.

For more information on malloc() implementations (including understanding fragmented free lists), the Wikipedia article is good: http://en.wikipedia.org/wiki/Malloc#Implementations

Oh, and memory leaks aren't acceptable, even in a test environment. As you can see, they're interfering with programs that (as far as you know) don't have leaks, and costing you time.

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