Memcached守护进程可以在不终止进程的情况下释放未使用的内存吗? [英] Can a Memcached daemon ever free() unused memory, without terminating the process?

查看:134
本文介绍了Memcached守护进程可以在不终止进程的情况下释放未使用的内存吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我相信,您不能强迫正在运行的Memcached实例取消分配内存,除非终止该Memcached实例(并释放其持有的所有内存).有谁知道可靠的资料,甚至可以肯定或否认这种印象的确定性文档,甚至邮件列表或博客发布?

I believe that you can't force a running Memcached instance to de-allocate memory, short of terminating that Memcached instance (and freeing all of the memory it held). Does anyone know of a definitive piece of documentation, or even a mailing list or blog posting from a reliable source, that can confirm or deny this impression?

据我了解,Memcached进程最初分配一块内存(确切的初始分配大小是可配置的),然后在整个生命周期内单调增加其内存利用率,这受守护程序的最大内存分配大小(也可配置)限制. Memcached守护程序绝不会释放任何内存,无论该守护程序是否对其存储的内存有任何持续需求.

As I understand it, a Memcached process initially allocates a chunk of memory (the exact initial allocation size is configurable), and then monotonically increases its memory utilization over its lifetime, limited by the daemon's maximum memory allocation size (also configurable). At no point does the Memcached daemon ever free any memory, regardless of whether the daemon has any ongoing need for the memory it holds.

我知道这个问题听起来有点古怪,语气是我要求开源项目X支持我的特定需求!"根本不是这样-我对这里的确切技术答案完全感兴趣,而且我发誓我对Memcached并不苛刻.出于好奇,这个问题来自一个讨论,即在给定应用程序中缓存刷新的成本可能很高的情况下,如何在单个服务器上适当地处理多个Memcached实例的方法.

I know that this question might sound a little whiny, with a tone of "I DEMAND that open source project X support my specific need!" That's not it, at all--I'm purely interested in the exact technical answer, here, and I swear I'm not harshing on Memcached. For the curious, this question came out of a discussion about possible methods for gracefully juggling multiple Memcached instances on a single server, given an application where the cost of a cache flush can be quite high.

但是,如果您为其他问题保存了应用程序建议/建议(重新构造我的应用程序,使用其他缓存实现等),我们将不胜感激.我的确很感激头脑风暴,但是我认为,如果该问题始终专注于Memcached如何工作和不工作的技术细节,那么它将是最有价值的.如果您没有针对这个特定问题的答案,那么您所说的话可能仍然有价值,但是我想您可以在另一个更好的地方发布更具投机性的评论/建议/建议.

However, I'd appreciate it if you save your application suggestions/advice for a different question (re-architecting my application, using a different caching implementation, etc.). I do appreciate a good brainstorm, but I think this question will be most valuable if it stays focused on the technical specifics of how Memcached does and does not work. If you don't have the answer to this specific question, there is probably still value in what you have to say, but I'd guess that there's a different, better place to post the more speculative comments/suggestions/advice.

推荐答案

这可能是我们目前必须解决的最重要的内存缓存问题(无论如何,还是它的一种变体).

This is probably the hardest problem we have to solve for memcached currently (well, a variation of it, anyway).

释放一块内存需要我们知道a)该块中没有任何东西正在使用,并且b)在我们为重新使用/释放而对其进行清理的过程中,没有任何东西会开始使用它.我听说过一些关于如何解决平板再平衡问题的非常好主意,这些想法基本上是相同的,除了我们不试图释放内存,而是将其分配给其他东西(一些大型安装中的常见问题). ).

Freeing a chunk of memory requires us to know that a) nothing within the chunk is in use and b) nothing will start using it while we're in the process of purging it for reuse/freeing. I've heard some really good ideas for how we might solve our slab rebalancing problems which is basically the same, except we're not trying to free the memory, but to give it to something else (a common problem in a few large installations).

此外,免费是否真的减少了您的流程的RSS取决于实现.在很多情况下,malloc/fill/free会将内存映射在其中(除非您的分配器使用mmap而不是sbrk).

Also, whether free actually reduces the RSS of your process is implementation dependent. In many cases, a malloc/fill/free will leave the memory mapped in (unless your allocator uses mmap instead of sbrk).

这篇关于Memcached守护进程可以在不终止进程的情况下释放未使用的内存吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆