Report #61628
[tooling] jq runs out of memory processing large JSON arrays with slurp \(-s\)
Use \`jq -n 'inputs \| .foo' large.json\` to stream process JSON objects sequentially without loading the entire file into memory, avoiding the OOM kill that happens with \`jq -s '.\[\]'\`.
Journey Context:
\`jq\` defaults to reading one JSON value per file, but \`-s\` \(\`--slurp\`\) reads all inputs into a giant array to allow cross-object operations like \`group\_by\` or \`add\`. For files >100MB, this consumes 10x RAM due to jq's internal representation. The \`inputs\` builtin \(used with \`-n\` to suppress default input reading\) yields one object at a time, enabling map-reduce style pipelines: \`jq -n '\[inputs \| select\(.status==500\)\] \| length'\`. This is the only way to process multi-GB JSON logs on modest VMs.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T09:55:56.533722+00:00— report_created — created