{
  "id": "android/room-cursor-window-allocation-failure",
  "signature": "android.database.CursorWindowAllocationException: Cursor window allocation of 2048 kb failed. # Open Cursors=10 (# cursors opened by this proc=10)",
  "signature_zh": "android.database.CursorWindowAllocationException: 游标窗口分配2048kb失败。打开游标数=10（本进程打开游标数=10）",
  "regex": "android\\.database\\.CursorWindowAllocationException.*Cursor window allocation.*failed",
  "domain": "android",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "Too many open cursors without proper closure, exceeding the per-process cursor limit (typically 100) or memory limit.",
  "root_cause_type": "generic",
  "root_cause_zh": "打开游标过多且未正确关闭，超出每进程游标限制（通常100个）或内存限制。",
  "versions": [
    {
      "version": "Room 2.5.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "SQLite 3.40.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Android 13 (API 33)",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Increasing heap size in AndroidManifest with android:largeHeap=true",
      "why_fails": "Does not address cursor leak; heap size increase delays but doesn't prevent crash.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "Adding try-finally blocks around cursor usage without using Room's LiveData or Flow",
      "why_fails": "Manual cursor management is error-prone; Room's reactive types handle lifecycle automatically.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Replace raw Cursor queries with Room's LiveData or Flow: @Query(\"SELECT * FROM users\") fun getAllUsers(): LiveData<List<User>>. This ensures cursors are closed when lifecycle ends.",
      "success_rate": 0.95,
      "how": "Replace raw Cursor queries with Room's LiveData or Flow: @Query(\"SELECT * FROM users\") fun getAllUsers(): LiveData<List<User>>. This ensures cursors are closed when lifecycle ends.",
      "condition": "",
      "sources": []
    },
    {
      "action": "If using raw Cursor, call cursor.close() in finally block and use ContentResolver.query with auto-close flag: val cursor = contentResolver.query(uri, null, null, null, null)?.use { it }",
      "success_rate": 0.85,
      "how": "If using raw Cursor, call cursor.close() in finally block and use ContentResolver.query with auto-close flag: val cursor = contentResolver.query(uri, null, null, null, null)?.use { it }",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Replace raw Cursor queries with Room's LiveData or Flow: @Query(\"SELECT * FROM users\") fun getAllUsers(): LiveData<List<User>>. This ensures cursors are closed when lifecycle ends.",
    "If using raw Cursor, call cursor.close() in finally block and use ContentResolver.query with auto-close flag: val cursor = contentResolver.query(uri, null, null, null, null)?.use { it }"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://developer.android.com/reference/android/database/CursorWindowAllocationException",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.88,
  "fix_success_rate": 0.92,
  "resolvable": "true",
  "first_seen": "2023-06-20",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}