Software DevelopmentAdvanced 3 to 5 hours

Profile and Fix a Memory Leak

Stop a Node.js server from continuously crashing out of memory.

The Scenario

A Node.js worker process processes CSV files. Every time a 100MB CSV file is processed, the server's RAM usage increases by 100MB and never goes down. Eventually, the container hits its 1GB limit and is killed by Kubernetes (OOMKilled).

The Brief

Diagnose the conceptual memory leak. You are given a code snippet that reads the entire file into an array using `fs.readFileSync`. Rewrite the logic to use Node.js Streams so it can process a 10GB file using only 50MB of RAM.

Deliverables

  • The refactored code using `fs.createReadStream` and a streaming CSV parser
  • An explanation of how Garbage Collection in V8 works, and why the original code prevented it

Submission Guidance

Streams are one of the most powerful but misunderstood features of Node.js. Your goal is to process the file chunk by chunk, without holding the whole thing in memory.

Submit Your Work

Your submission is graded against the rubric on the right. If you pass, you get a public Badge URL you can share on LinkedIn. There is no draft save, so work offline first and paste your finished response here.

This appears on your public Badge.

0/20000 charactersMarkdown supported

One per line or comma separated. Up to 5 links.

By submitting, you agree your submission text, name, and evaluation will appear on a public Badge URL.