# Redis内存不足：已用内存超过'maxmemory'时不允许执行命令

- **ID:** `data/redis-oom-command-not-allowed`
- **领域:** data
- **类别:** resource_error
- **错误码:** `OOM`
- **验证级别:** ai_generated
- **修复率:** 87%

## 根因

Redis达到配置的maxmemory限制，且逐出策略设置为noeviction，导致写入命令因内存不足而失败。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| Redis 6.2 | active | — | — |
| Redis 7.0 | active | — | — |
| Redis 7.2 | active | — | — |

## 解决方案

1. ```
   Change the eviction policy to allkeys-lru to automatically evict least recently used keys when memory is full.
   ```
2. ```
   Add more RAM to the server and increase maxmemory to a safe limit below total RAM.
   ```

## 无效尝试

- **** — Without setting an eviction policy, Redis will fill up again quickly. (85% 失败率)
- **** — If the system has no free RAM, Redis will swap to disk, severely degrading performance. (75% 失败率)
