{
  "id": 19958434,
  "title": "Loading a 72 MB JSON list on a TV box without running out of memory",
  "url": "https://urgent.news/2026/11/14/loading-a-72-mb-json-list-on-a-tv-box-without-running-out-of-memory",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-11-14T09:52:38.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/usama_muhammad_d144933dd0/loading-a-72-mb-json-list-on-a-tv-box-without-running-out-of-memory-n33"
  },
  "original_language": "en",
  "account": "A media player for Android TV boxes, phones and Windows was created by the author. Users sign in with a playlist provided by their service, and the app downloads three lists from the provider's server: live channels, films and series. Each list is a single JSON array that can be large, such as 72 MB for one list or 131 MB when combining three lists. The author discovered that downloading and parsing such large lists directly on an Android TV box with 4 GB of RAM could cause memory issues, leading to crashes and empty playlists.\n\nTo address this problem, the author implemented a fix where the JSON list is streamed instead of being downloaded as a whole. This stream reads the list as the bytes arrive, piece by piece, which prevents the entire list from being held in memory at once. The process then cuts the array and parses each item separately, reducing the number of large parses and allowing for better memory management. The splitter, which handles the array parsing, reads only 2,000 items at a time and hands these items to JSON.parse on their own.\n\nAnother optimization the author made was to save the rows in fixed blocks, using a single prepared INSERT statement that can be reused. This prevents memory allocation from growing as the list is parsed. Additionally, the author addressed issues with backslashes and non-ASCII characters, which could cause performance issues when parsing the JSON. By handling these characters correctly, the parsing time became consistent regardless of the specific content within the list.\n\nFor Android devices, the author further optimized the process by first saving the list as a file in the cache folder using native code. The list is then read back in megabyte chunks, which keeps the memory usage low and improves performance compared to reading the entire list at once. If the device has less than 300 MB of free memory or cannot write the file, the app falls back to reading the list as it arrives.\n\nThe author recommends testing on the target device, treating memory issues as possible causes for \"Network request failed,\" and avoiding using response.json() on large JSON lists. Batching data into fixed sizes and testing with real-world data containing escaped slashes and non-ASCII characters are advised for better performance in React Native apps. The techniques discussed can be applied to any application that requires loading large JSON data on devices with limited memory.",
  "summary": "I make a media player for Android TV boxes, phones and Windows. People sign in with the playlist their provider gives them, and the app downloads three lists from the provider's server: live channels, films and series. Each one is a single JSON array. On paper that is easy: await (await fetch(url)).json() . In practice it broke on real hardware, and the fix taught me more about memory on cheap…",
  "key_points": [
    "JSON list of 72 MB downloaded and parsed on Android TV box causes memory issues",
    "Stream JSON list instead of downloading as whole to prevent memory crashes",
    "Save rows in fixed blocks with single prepared INSERT statement for better memory management"
  ],
  "editors_take": "Streaming large JSON datasets and processing them in small, fixed batches allows resource-constrained media players to handle massive playlists without triggering memory crashes or performance degradation.",
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}