# FT.CREATE 失败：为索引 'myidx' 分配内存时内存不足

- **ID:** `redis/redisearch-index-out-of-memory`
- **领域:** redis
- **类别:** resource_error
- **错误码:** `ERR`
- **验证级别:** ai_generated
- **修复率:** 78%

## 根因

Redis Search 模块因 maxmemory 限制或系统内存不足，无法为新索引分配内存。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 7.2.0 | active | — | — |
| 7.4.0 | active | — | — |
| 8.0.0 | active | — | — |

## 解决方案

1. ```
   增加 maxmemory：CONFIG SET maxmemory 2gb。然后重试 FT.CREATE。使用 INFO memory 监控。
   ```
2. ```
   删除未使用的索引以释放内存：FT.DROPINDEX oldidx DD（DD 删除文档）。然后重试。
   ```
3. ```
   通过在 FT.CREATE 中使用更少的字段或更小的文本字段来减少索引内存开销（例如，关闭 WITHSUFFIXTRIE）。
   ```

## 无效尝试

- **** — Setting maxmemory-policy to noeviction prevents eviction but also blocks new writes including index creation; it doesn't free memory. (70% 失败率)
- **** — Deleting the index key with DEL may not free memory immediately if the index is still referenced by internal structures; use FT.DROPINDEX instead. (60% 失败率)
