Last week I was profiling a Node.js service that processes large JSON-RPC responses. Three concurrent 18.7 MB responses crashed the process with an out-of-memory error — on a machine with 1 GB of heap.
The culprit wasn't the JSON parser. It was the UTF-8 decoder that ran before JSON.parse ever saw the data.
The setup
The service fetches binary response bodies as Uint8Array and converts them to strings before parsing. The conversion function looked something like this:
function toUtf8String(bytes) {






