Well... I'm back to square one. I can't figure this out for the life of me.
I'm getting the following error:
FATAL ERROR: JS Allocation failed - process out of memory
I could enumerate the dozens (yes, dozens) of things I've tried to get to the root of this problem, but really it would be far too much. So here are the key points:
My assumption is that (because of the 2nd point), a leak is probably not the cause; rather, it seems like there's probably a SINGLE object that is very large. The following thread backs up this theory:: In Node.js using JSON.stringify results in 'process out of memory' error
What I really need is some way to find out what the state of the memory is at the moment the application crashes, or perhaps a stack trace leading up to the FATAL ERROR.
Based upon my assumption above, a 10-minute-old heap dump is insufficient (since the object would have not resided in memory).
This exception can be solved by increasing the default memory allocated to our program to the required memory by using the following command. Parameters: SPACE_REQD: Pass the increased memory space (in Megabytes).
To fix JavaScript heap out of memory error, you need to add the --max-old-space-size option when running your npm command. Alternatively, you can also set the memory limit for your entire environment using a configuration file.
By default, the memory limit in Node. js is 512 MB. To increase this amount, you need to set the memory limit argument —-max-old-space-size . It will help avoid a memory limit issue.
Just because this is the top answer on Google at the moment, I figured I'd add a solution for a case I just ran across:
I had this issue using express with ejs templates - the issue was that I failed to close an ejs block, and the file was js code - something like this:
var url = '<%=getUrl("/some/url")' /* lots more javascript that ejs tries to parse in memory apparently */
This is obviously a super specific case, OP's solution should be used the majority of the time. However, OP's solution would not work for this (ejs stack trace won't be surfaced by ofe
).
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