Debugging high memory usage

memory , nodejs , oom , programming , debugging

Step 1: Identify Where It’s Happening #

Here’s what I did:

Step 2: Track Function Calls and Memory Usage #

Step 3: Inspect further #

Step 4: Optimize the Root Cause #

In my case, the culprit was SheetJS, which caused memory leaks when reading a huge file. I replaced it with ExcelJS using streaming writes. I also implemented an async generator function to further reduce memory usage while reading a large the JSONL file, which i use to generate the report.

Most of your time will likely be spent on debugging. Once the issue is found and reliably reproducible, resolving it becomes much easier.

That’s it for this one!

Thanks for reading, and happy debugging! 😊