Fatal error in CALL_AND_RETRY_2 (out of memory)

Jan 13, 2011 at 10:22 AM

I get this error in a test application which runs the following loop:

  Create JavascriptContext
  Load 88k of javascript
  Call a method in the javascript loaded
  Discard the context

Initially this runs very quickly (9mS per iteration) but by the 4500th iteration it suddenly slows significantly (200mS) and after 4800 iterations it finally bombs after a few seconds delay with the message:

# Fatal error in CALL_AND_RETRY_2
# Allocation failed - process out of memory

This occurs even when I explicitly call the C# GC at the end of the loop:

GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced);
after nulling the JavascriptContext reference.  Is there something I should be doing to ensure that each iteration properly cleans up after itself.

The Javascript code is a templating engine which does a lot of string processing and data structure building/access but no I/O whatsoever.



Jan 13, 2011 at 12:47 PM

Interestingly, the slow-down and eventual memory fault disappear if you hoist the JavascriptContext create/destroy out of the loop. In this case it will happily run for 100000 iterations with no detectable GC pauses.

Mar 17, 2011 at 10:19 AM

Not sure to understand your question, but I'm experiencing pbs with the memory also. When you write "Discard the context", do you mean this: context.Dispose(); ? If I don't do that, my RAM keeps on growing...

Aug 9, 2011 at 4:35 PM
Edited Aug 9, 2011 at 4:38 PM

Same issue here. Indeed it looks like you have to discard the context after running your script.