SERVER-134946ClosedFixed
Spurious JSInterpreterFailure "Out of memory"
Server-side JavaScript fails with {{JSInterpreterFailure}} "Out of memory" while the actual SpiderMonkey heap is nearly empty. MongoDB's JS memory counter ({{{}mongo::sm::malloc_bytes{}}}) is incremented when a {{mozilla::StringBuffer}} is allocated but never decremented when it is released, so it tracks cumulative string allocation instead of live memory. Once it crosses {{internalQueryJavaScriptHeapSizeLimitMB}} (default 100MB) the operation is killed.