Snailclimb / Snailclimb/JavaGuide

redis内存回收

Open
#872 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

discuss help wanted
Dominant language
JavaScript
Stars
159k
Forks
46.1k
Avg merge
14h 36m
Merged PRs (30d)
6

Description

如redis-内存回收和内存共享部分所描述: 因为c语言不具备自动内存回收功能,当将redisObject对象作为数据库的键或值而不是作为参数存储时其生命周期是非常长的,为了解决这个问题,Redis自己构建了一个内存回收机制,通过redisobject结构中的refcount实现.这个属性会随着对象的使用状态而不断变化。
1、创建一个新对象,属性初始化为1
2、对象被一个新程序使用,属性refcount加1
3、对象不再被一个程序使用,属性refcount减1
4、当对象的引用计数值变为0时,对象所占用的内存就会被释放
其中不太理解如何进行这种基于refcount的引用计数回收,对于过期的数据进行的是定期删除和惰性删除,当内存要溢出时进行的是淘汰机制(noeviction、volatile-lru等),但是文中所描述的这种引用计数的回收方式在何时进行呢?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Redis memory reclamation and memory sharing sections referenced in the issue, then review the explanation of redisObject and refcount alongside the expiration and eviction descriptions. Done means the documentation clearly explains when reference-counted objects are released and how that differs from expiration and eviction.

Written by the indexing model from the issue text.

Assessment

Tech stack
redis
Domain
documentation
Issue type
Documentation
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.