OOM: Memory limit reached
The dataset reached the maxmemory limit and the eviction policy cannot free enough memory, so Redis refuses write commands.
- Error prefix
OOM
의미
OOM is the write-path refusal when used_memory is over maxmemory and the configured maxmemory-policy cannot free enough: noeviction evicts nothing by definition, and even an allkeys policy can fail when the incoming write is larger than what eviction can reclaim. Read commands keep working, and so do commands without the deny-oom flag, such as DEL; a SET is refused at the limit even when the new value is smaller.
The message names the two knobs precisely: the ceiling is maxmemory and the behavior at the ceiling is maxmemory-policy. Which one to change depends on what the data is: a cache wants an eviction policy; a system of record wants more memory or a smaller dataset.
일반적인 원인
- maxmemory is set and the working set grew past it, with the policy at its default of noeviction.
- An allkeys or volatile policy still could not free enough for the incoming write.
- A single very large value arrives at a moment when eviction has already freed everything it can.
Find the cause
INFO memory # used_memory versus maxmemory, and the policy in force INFO stats | grep evicted # How often eviction already ran to make room redis-cli --bigkeys # Where the bytes are: the largest keys by type
maxmemory policies at the limit
| noeviction | The default. Write commands are refused with OOM, including ones that would not grow memory; reads keep working. |
|---|---|
| allkeys-lru / allkeys-lfu | Evicts the least recently or least frequently used key, across all keys, to fit the write. |
| volatile-* | Evicts only keys with a TTL. When no key has one, it behaves like noeviction. |
| allkeys-random / volatile-random | Evicts a random key from the eligible set. |
해결 방법
-
See where you stand before changing anything:
INFO memory # used_memory_human, maxmemory_human, maxmemory_policy CONFIG GET maxmemory
-
For a cache, let Redis free space itself by switching the policy:
CONFIG SET maxmemory-policy allkeys-lru
-
For data that must not be evicted, raise the limit or shrink the dataset, then persist the change:
CONFIG SET maxmemory 2gb CONFIG REWRITE
Other ways to handle it
Split by tier: keep evictable data such as sessions and caches in one instance with allkeys-lru, and durable data in another with noeviction plus alerts on used_memory. On the client, tolerate OOM for best-effort writes but never for ledger-style ones.
안전하게 재현하세요
redis-server --port 7306 --maxmemory 2mb --maxmemory-policy noeviction --save '' & head -c 3000000 /dev/zero | tr '\0' 'a' | redis-cli -p 7306 -x SET big # (error) OOM command not allowed when used memory > 'maxmemory'.
질문
Why do reads still work when writes get OOM?
The limit guards memory growth. Reads are not flagged to be refused at the limit, so Redis serves them, while write commands flagged deny-oom are refused whether or not they grow the dataset.
What does maxmemory 0 mean?
No Redis-side limit: the process grows until the operating system stops it. The OOM refusal only applies when maxmemory is set to a byte value.
관련 오류
Out of Memory ErrorDuckDB: The query hit DuckDB's memory limitSQLITE_NOMEMSQLite: 메모리 부족53200PostgreSQL: 메모리 부족701SQL Server: 리소스 풀의 메모리 부족
More memory and persistence errors
MISCONFPersistence is failing, writes stoppedLOADINGDataset still loading from diskBUSYKEYTarget key already exists
코드와 메시지 텍스트의 출처는 다음과 같습니다 Redis documentation and source code. 전체 목록은 Redis error list 또는 모든 데이터베이스 오류 검색.
Work on Redis in SQLly
A native SQL client for macOS, Windows and Linux with schema-aware IntelliSense, guardrails for risky statements and clear error messages, for Redis and the other databases you use.
이 페이지의 텍스트와 데이터: CC BY 4.0, 출처: SQLly (sqlly.app). 코드와 SQL 스니펫: MIT. 라이선스 세부 정보 인용된 오류 메시지 텍스트의 권리는 해당 데이터베이스 공급업체에 있습니다.