-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FATAL ERROR: CALL_AND_RETRY_2 Allocation failed - process out of memory #668
Comments
@ScorpioKing, could we see a full gist of the code? I'm guessing either the file stream isn't opened fast enough (or at all), or it's not flushing fast enough: the logs end up getting buffered. (Or, there's some strange memory leak with hanging reachable variables in the FileTransport.{log,_write} methods, but I doubt it). Best way to test this would be to rip out all the buffering code in the file transport and run @ScorpioKing's code. Thoughts? |
@chjj for(var i = 0 ; i < 1000000 ; i++){
logger.debug("DEBUG JJ: ",i);
if (n < 2 ) {
logger.debug("Not a prime number !!!");
}else{
// Now assume that n is prime, we will try to prove that it is not.
var isPrime = true;
// Now check every whole number from 2 to the square root of n. If any of these divides n exactly, n cannot be prime.
for (var i = 2; i <= Math.sqrt(n); i++) {
if (n % i == 0) {
isPrime = false;
}
}
if(isPrime){
logger.debug("Prime number !!!");
}else{
logger.debug("Not a prime number !!!");
}
}
}; If i comment out whole code and put this only for(var i = 0 ; i < 1000000 ; i++){
logger.debug("DEBUG JJ: ",i);
}; Then also i am getting this
|
I met this problem as well.
Thanks |
Why are these results surprising to you? You are attempting to log one million messages in a single node process in the same tick. Do you get one million requests per millisecond in your web application? |
FWIW, I'm seeing the same thing with much more modest output (a couple ES6 classes), and logging to console. trailsjs/trailpack-repl#20. Using console.log() works fine. |
@tjwebb, the root cause is that, console.log() is synchronized call, while winstonjs and log4js are asynchronized. It means, it needs a chance to do the underlying writing, or the content will be buffered until the memory ran out. Root Cause This is caused by the event loop mechanisms of nodejs, bool ev_run (loop, int flags), it takes an task idle -> I/O -> check The 'for' and 'process.nextTick()' are idle watchers, so the Solution So, we need to give the logger a chance to do the underlying work. example main.js for winston
|
@alphatan have you tested this fix? For me, this only happens when I have the REPL running. console.log works, and winston without the REPL works. but Winston + REPL = bad. My process doesn't just run out of memory, it hangs for about 3-4 minutes and then crashes with that error. I guess in that time it's in some sort of infinite loop. Why would this behavior result from winston not being able to write its output in a single tick? Also fwiw, this occurs in both node 4 and 5. |
This issue is really confusing. For example, this works fine for me:
But logging two instantiated ES6 classes with two static properties fails. It can't be only about object size. |
This is interesting. So my line app.log(app.models) Fails in the above way. However, if I first wrap it in
Could it be that winston isn't handling this properly, and it's sending it into this kind of tailspin? |
@indexzero it looks like, in my case, this is resulting from an unhandled exception in winston. If I disable
It's failing here: https://github.com/winstonjs/winston/blob/master/lib/winston/common.js#L325. In ES6 (node 4 and later) there are new built-in types in addition to the ones that winston is specifically looking for, and it's choking. For example, we cannot assume that object keys are only strings. As far as why/how this metatsizes into a giant memory leak, I have no idea. |
@indexzero I updated common.js to detect Symbols using I'll do a bit more research and see if I can find out why prettyPrint is causing things to break |
I am setting up telescope on my localhost. When I am downloading meteor using cmd then I am getting |
is this problem related to nodejs/node#3524 (comment) ? |
Hello,
I am using File Transport.
My Code Snippet
After executing this code i am getting
As i am iterating using for loop and taking logs into file, winston is doing so much of file write operation.
Please tell me some solution for this.
The text was updated successfully, but these errors were encountered: