Fix Redis Memory Full — Eviction & Memory Management

Direct answer

Redis returns OOM errors when used memory exceeds the maxmemory limit and the eviction policy is set to noeviction. Set maxmemory-policy to allkeys-lru for automatic eviction of least recently used keys, and add TTL to all cache keys to prevent unbounded growth.

Structured breakdown

Cause

When Redis runs out of memory, writes fail with OOM errors. Set a maxmemory-policy (e.g., allkeys-lru) to auto-evict old keys, and audit key expiration to prevent unbounded growth.

Fix

  • Set maxmemory-policy to allkeys-lru or volatile-lru for automatic eviction
  • Add TTL (EXPIRE) to all cache keys to prevent unbounded growth
  • Run redis-cli INFO memory to check used_memory and fragmentation ratio

Outcome

Redis accepts writes again with an eviction policy in place, and key TTLs prevent unbounded memory growth.

Common causes

  • No maxmemory-policy configured (default is noeviction)
  • Keys stored without TTL, growing indefinitely
  • Large data structures (sorted sets, lists) consuming excessive memory
  • Memory fragmentation ratio is high
  • Instance size is undersized for the dataset

Fix steps

  1. 1

    Set maxmemory-policy to allkeys-lru or volatile-lru for automatic eviction

  2. 2

    Add TTL (EXPIRE) to all cache keys to prevent unbounded growth

  3. 3

    Run redis-cli INFO memory to check used_memory and fragmentation ratio

  4. 4

    Identify large keys with redis-cli --bigkeys and optimize or remove them

  5. 5

    Scale up the Redis instance or add a Redis Cluster for larger datasets

Analyze this issue

Paste the issue description, logs, or symptoms into the fix tool to inspect this problem with your own runtime details.

kintify fix

Need more context?

If the standard steps do not resolve the issue, open the fix tool and include the current logs, configuration, and deployment changes.

Open Fix Tool

Frequently asked questions

These examples show the commands, logs, and configuration patterns most often used to verify this issue.

Command examples

  • redis-cli INFO memory
  • redis-cli --bigkeys
  • redis-cli CONFIG SET maxmemory-policy allkeys-lru

Log snippet

OOM command not allowed when used memory > 'maxmemory'
used_memory_human:256.12M
maxmemory_human:256.00M
maxmemory_policy:noeviction

Config snippet

# redis.conf
maxmemory 512mb
maxmemory-policy allkeys-lru
maxmemory-samples 10