{
  "id": "java/outofmemoryerror-direct-buffer-memory",
  "signature": "java.lang.OutOfMemoryError: Direct buffer memory",
  "signature_zh": "java.lang.OutOfMemoryError：直接缓冲区内存",
  "regex": "java\\.lang\\.OutOfMemoryError: Direct buffer memory",
  "domain": "java",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "The JVM has exhausted the off-heap memory limit (MaxDirectMemorySize) for direct byte buffers, typically caused by allocating many direct ByteBuffers without releasing them, or by NIO operations that leak direct memory.",
  "root_cause_type": "generic",
  "root_cause_zh": "JVM 已耗尽直接字节缓冲区的堆外内存限制（MaxDirectMemorySize），通常由分配大量直接 ByteBuffer 而不释放，或 NIO 操作泄漏直接内存引起。",
  "versions": [
    {
      "version": "Java 8",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Java 11",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Java 17",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Java 21",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Increasing heap space (-Xmx) does not affect direct memory limits; direct memory is separate from heap.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Enabling GC logging without tuning direct memory does not prevent the leak; it only helps diagnose.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Setting MaxDirectMemorySize to a very high value only delays the crash; the underlying leak continues.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Ensure direct ByteBuffers are explicitly released after use by calling the cleaner or using try-with-resources if possible. For Netty or other NIO frameworks, check for buffer pooling and leak detection.",
      "success_rate": 0.85,
      "how": "Ensure direct ByteBuffers are explicitly released after use by calling the cleaner or using try-with-resources if possible. For Netty or other NIO frameworks, check for buffer pooling and leak detection.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Increase the MaxDirectMemorySize JVM parameter to accommodate legitimate direct memory usage, but also implement proper cleanup.",
      "success_rate": 0.75,
      "how": "Increase the MaxDirectMemorySize JVM parameter to accommodate legitimate direct memory usage, but also implement proper cleanup.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use a memory-mapped file or heap-based ByteBuffer instead of direct ByteBuffer when possible, to avoid off-heap memory pressure.",
      "success_rate": 0.7,
      "how": "Use a memory-mapped file or heap-based ByteBuffer instead of direct ByteBuffer when possible, to avoid off-heap memory pressure.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Ensure direct ByteBuffers are explicitly released after use by calling the cleaner or using try-with-resources if possible. For Netty or other NIO frameworks, check for buffer pooling and leak detection.",
    "Increase the MaxDirectMemorySize JVM parameter to accommodate legitimate direct memory usage, but also implement proper cleanup.",
    "Use a memory-mapped file or heap-based ByteBuffer instead of direct ByteBuffer when possible, to avoid off-heap memory pressure."
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/OutOfMemoryError.html",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.85,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2023-10-25",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}