user1823073
user1823073

Reputation: 11

What is the correct condition to check [when maxmemory is reached] in Redis

I've quoted the following from the configuration file of Redis:

...
maxmemory

MAXMEMORY POLICY: how Redis will select what to remove when maxmemory
is reached? You can select among five behavior:
...

And here my question goes: What is the correct condition to check when maxmemory is reached?

First, I thought the answer is [used_memory >= maxmemory], where used_memory is showed by the INFO command.

But, now I am confusing that the answer maybe [used_memory_rss >= maxmemory].

What is the correct answer?

Upvotes: 0

Views: 549

Answers (2)

Didier Spezia
Didier Spezia

Reputation: 73226

The maxmemory parameter is compared to a value calculated from used_memory, not used_memory_rss.

Now, the exact behavior is not trivial, because Redis tries to estimate the amount of memory taking in account master/slave replication, and AOF buffering. The value is used_memory (as calculated by the allocator wrapper) minus the size of slaves output buffers, minus the size of AOF buffers. Then this value is compared to maxmemory.

Upvotes: 0

Related Questions