I'm trying to write a program that downloads a large zip file, unzips it in memory, and then pushes the contents (a series of CSV files) to MongoDB. However, I keep hitting a point where the program halts and prints
FATAL ERROR: CodeRange::GetNextAllocationBlock Allocation failed - process out of memory
I've been setting buffers to null when they're no longer in use, setting records to null once they're in Mongo, and preventing more than one file from processing at a time. None of this has helped. Are there any more tricks to releasing memory?
At least 2GB of RAM.
Avoid Accidental Globals This could be the result of a typo and could lead to a memory leak. Another way could be when assigning a variable to this within a function in the global scope. To avoid issues like this, always write JavaScript in strict mode using the 'use strict'; annotation at the top of your JS file.
This error usually occurs when the default memory allocated by your system to Node. js is not enough to run a large project. The error is common whether you run your project on Windows, macOS, or a Linux distribution like Ubuntu.
Somethings I would consider would be(not sure if it will all work out as desired):
Make sure references are gone:
Performing GC manually and increase v8 heap size:
Spawning(and killing) child process from parent process to do work:
That way I think the OS will reclaim memory for child process even if it is not returning memory.
Ram as filesystem:
That way you can treat filesystem as memory(let operating system put it into memory).
Use freelist:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With