Hello,
Redis always uses the peak memory usage during it's life, unless you
*restart* it from scratch.
So basically if you want to use 5 GB for 10 seconds, and all the other
day you use 100 MB, you need 5 GB of memory free always as after the
peak memory usage it will never release the memory again.
This is not going to change in the future for a number of technical reasons.
Cheers,
Salvatore
On Thu, Mar 14, 2013 at 3:49 PM, Andras Zimmer <
andras...@gmail.com> wrote:
> First and foremost: thanks for Redis! It's versatile and capable -- meets
> pretty much all of our DB-in-memory needs. Having used it for a while I
> have a few questions about its memory allocation (or more precisely:
> release) behavior.
>
> Background: Our application uses Redis on Ubuntu 12.04:
> redis_version:2.6.10; mem_allocator: jemalloc-3.2.0. We have three major use
> cases for the Redis DB:
>
> keys that have list values and that expire in 1-2 days, there are a ton of
> these
> keys that get DEL'd at the end of their useful life (usually less than an
> hour) -- they are of various types and they are also numerous
> a handful of keys that live for a long time (mostly lists and sets) -- but
> their content change heavily
>
> After weeks of uptime I realized that the amount of memory allocated to
> Redis slowly but constantly grew. I know that the "live" (non-expired,
> non-deleted keys (along with content)) must not require even close to 100MBs
> of memory -- but Redis was using nearly 800MBs. I double checked and there
> were only a few "leftover" objects in the DB that I DEL'd. No surprise,
> nothing changed.
>
> I then checked and realized that maxmemory was not set. So I set it from
> redis-cli with 'config set maxmemory 629145600' to 600MB in the hopes that
> Redis will free 200MB. I had to stop the server a few hours later anyway so
> I didn't do a thorough test but it looked like to me that Redis did not in
> fact free up any memory; altough it seemed not to allocate more. Thus comes
> question #1:
>
> Q1: What is Redis's memory release policy if maxmemory is manually configed
> to a smaller amount than what is already allocated by Redis? (And as a
> corrolary: is there any other way to force Redis to "shrink" rest of
> restarting it?)
>
> Having read docs (at least trying -- better late than never :)) I'm still
> unsure of a few things:
>
> Q2: When does Redis release memory allocated for items that get DEL'd: at
> near DEL time, at the time it would re-use the memory (so effectively it is
> reluctant to ever give up on it), at approaching maxmemory, or at some other
> time?
>
> Q3: What happens (memory-wise) with list and set items that get removed from
> keys (when the keys themselves don't get removed)? Do they get freed
> individually or only when the key itself is removed? (See use case 3
> above.)
>
> Q4: Am I right in that Redis will get rid of expired items only when using
> 'maxmemory-policy volatile-lru' (the default). The doc says: "remove the
> key with an expire set using an LRU algorithm": so might it be possible that
> Redis removes items that have their expiry set but not yet expired? If so
> does Redis prefer actually expired items when evicting keys?
>
> I would appreciate any help with these -- and I'm sorry in advance if they
> are documented but I was too sloppy in my reading.
>
> Regards,
>
> Andras
>
> --
> You received this message because you are subscribed to the Google Groups
> "Redis DB" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to
redis-db+u...@googlegroups.com.
> To post to this group, send email to
redi...@googlegroups.com.
> Visit this group at
http://groups.google.com/group/redis-db?hl=en.
> For more options, visit
https://groups.google.com/groups/opt_out.
>
>
--
Salvatore 'antirez' Sanfilippo
open source developer - VMware
http://invece.org
Beauty is more important in computing than anywhere else in technology
because software is so complicated. Beauty is the ultimate defence
against complexity.
— David Gelernter