I ran it with v0.10.15 initially. With v0.8.22, it's been running for over 1.5 hours now, with no problems. So I still think the problem must be with the "..." sections.
-- Martin Cooper On Mon, Aug 26, 2013 at 10:28 PM, ming <hseum...@gmail.com> wrote: > Hi Martin, > Thanks for the input. i was a bit surprised to learn that. What version > of node are you running over there? > > i should have mentioned that the version of Node i use is 0.8.22. Not > sure if that plays any role in the crash. i know 0.8.22 is not the latest > (and likely the greatest) but that's what i'm stuck with. Whether/when > the resource will be depleted also depends on the macho-ness of the bare > metal, :-) > > > > > On Friday, August 23, 2013 8:34:49 PM UTC-4, Martin Cooper wrote: > >> I think you'll find that the problem is in one of the "..." sections >> you've omitted. Your foo1 code has been running on my machine all day >> without any issue at all. >> >> -- >> Martin Cooper >> >> >> On Wed, Aug 21, 2013 at 8:22 PM, ming <hseu...@gmail.com> wrote: >> >>> Hi, >>> My node.js program crashed and i saw the following in the log: >>> FATAL ERROR: CALL_AND_RETRY_2 Allocation failed - process out of memory >>> >>> i reduced the original program to the following tiny self-contained program: >>> >>> ============================= >>> ... >>> >>> function foo1() >>> { >>> var someBadURI = ...; >>> >>> http.get >>> ( >>> someBadURI, >>> function(res) >>> { >>> if (res.statusCode != 200) >>> { >>> util.log("!!!!! bad ...."); >>> setTimeout(foo1,0); >>> return; >>> } ... >>> } >>> ) ... >>> } >>> >>> foo1(); >>> ============================= >>> >>> If i let the program above run long enough (~30 minutes or more), the >>> process ran out of memory then crashed with the aforementioned error >>> message but it is not clear to me why: >>> FATAL ERROR: CALL_AND_RETRY_2 Allocation failed - process out of memory >>> >>> However, the following program has been running for days without any >>> problem: >>> >>> ============================= >>> function foo2() >>> { >>> util.log("entering foo2"); >>> setTimeout(foo2,0); >>> util.log("leavinging foo2"); >>> } >>> >>> foo2(); >>> ============================= >>> >>> Why is that? Should the V8 engine register the event and invoke the >>> callback/handler constantly with 0-wait setTimeout? Why would it consume >>> a lot of memory? >>> >>> My guess is >>> * memory has been allocated for the http.get call in foo1. >>> In foo2, there is only log printing which does not really consume any >>> resource (memory in this case) >>> >>> * the call >>> setTimeout(foo,0); >>> in foo1 always grabs the next tick so the GC never gets a chance to run >>> >>> Am i way off? i'm unsure if i need to yank in scoped, handle, context, >>> etc. into my reasoning though for a better description. >>> >>> Thanks. >>> >>> -- >>> -- >>> Job Board: http://jobs.nodejs.org/ >>> Posting guidelines: https://github.com/joyent/**node/wiki/Mailing-List-* >>> *Posting-Guidelines<https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines> >>> You received this message because you are subscribed to the Google >>> Groups "nodejs" group. >>> To post to this group, send email to nod...@googlegroups.com >>> >>> To unsubscribe from this group, send email to >>> nodejs+un...@**googlegroups.com >>> >>> For more options, visit this group at >>> http://groups.google.com/**group/nodejs?hl=en?hl=en<http://groups.google.com/group/nodejs?hl=en?hl=en> >>> >>> --- >>> You received this message because you are subscribed to the Google >>> Groups "nodejs" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to nodejs+un...@**googlegroups.com. >>> >>> For more options, visit >>> https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out> >>> . >>> >> >> -- > -- > Job Board: http://jobs.nodejs.org/ > Posting guidelines: > https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines > You received this message because you are subscribed to the Google > Groups "nodejs" group. > To post to this group, send email to nodejs@googlegroups.com > To unsubscribe from this group, send email to > nodejs+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/nodejs?hl=en?hl=en > > --- > You received this message because you are subscribed to the Google Groups > "nodejs" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to nodejs+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/groups/opt_out. > -- -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups "nodejs" group. To post to this group, send email to nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en --- You received this message because you are subscribed to the Google Groups "nodejs" group. To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.