# 内存溢出：Java堆空间（字段缓存逐出）

- **ID:** `elasticsearch/field-cache-eviction-out-of-memory`
- **领域:** elasticsearch
- **类别:** resource_error
- **验证级别:** ai_generated
- **修复率:** 78%

## 根因

字段数据缓存或过滤器缓存消耗过多堆内存，逐出操作导致 JVM 无法释放足够空间而触发内存溢出。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 7.10.2 | active | — | — |
| 8.0.0 | active | — | — |
| 8.12.1 | active | — | — |

## 解决方案

1. ```
   在 elasticsearch.yml 中减少字段数据缓存大小：indices.fielddata.cache.size: 20% of heap。重启节点使更改生效。
   ```
2. ```
   启用字段数据断路器并设置较低限制：PUT /_cluster/settings { "persistent": { "indices.breaker.fielddata.limit": "30%" } }
   ```

## 无效尝试

- **** — Larger heap only delays the OOM; the field cache can still grow unbounded and eventually exhaust memory. (80% 失败率)
- **** — Disabling the cache causes severe performance degradation for aggregations and sorting on text fields, leading to query failures. (90% 失败率)
