slot已经迁移到其他节点,但是,内存未释放

问一下, 我当前节点上有1200个slot,占用的物理内存大概是17.4G, 我把其中的200个slot迁移到其他节点了, 但是,查看redis的物理内存占用,只是少了几百K, 几乎是没有释放,请问,这是啥原因啊? 求大神们指点一下。 谢谢!...显示全部

问一下, 我当前节点上有1200个slot,占用的物理内存大概是17.4G, 我把其中的200个slot迁移到其他节点了, 但是,查看redis的物理内存占用,只是少了几百K, 几乎是没有释放,请问,这是啥原因啊? 求大神们指点一下。 谢谢!

收起
参与7

查看其它 2 个回答liucj2004的回答

liucj2004liucj2004其它undefined

https://redis.io/topics/memory-optimization
Memory allocation这一章节
Redis will not always free up (return) memory to the OS when keys are removed. This is not something special about Redis, but it is how most malloc() implementations work. For example if you fill an instance with 5GB worth of data, and then remove the equivalent of 2GB of data, the Resident Set Size (also known as the RSS, which is the number of memory pages consumed by the process) will probably still be around 5GB, even if Redis will claim that the user memory is around 3GB. This happens because the underlying allocator can't easily release the memory. For example often most of the removed keys were allocated in the same pages as the other keys that still exist.
简单说,因为内存交给系统管理,所以删除(迁移走)key时不会很快的释放内存。
要很快释放的话,冻结主节点,让从节点接管,重启原主节点,然后再接管回来。

农业其它 · 2017-05-05
浏览2903

回答者

liucj2004 最近回答过的问题

回答状态

  • 发布时间:2017-05-05
  • 关注会员:3 人
  • 回答浏览:2903
  • X社区推广