ExportXMLWordPrintableJSON

    • Type: Bug
    • Resolution: Unresolved
    • Priority: Major - P3
    • None
    • Affects Version/s: 8.0.32
    • Component/s: None
    • None
    • Query Integration
    • ALL
    • Hide

      Any StringBuilder-based builtin producing non-inline strings; Array.prototype.join

      db.c.insertOne({_id: 0});
      db.c.aggregate([{$addFields: {y: {$function: {
        body: "function(){ const a=[]; for(let i=0;i<1000;i++) a.push('xxxxxxxxxx');" +
              " let t=0; for(let i=0;i<20000;i++) t += a.join('').length; return t; }",
        args: [], lang: "js"}}}}]);
      Show
      Any StringBuilder-based builtin producing non-inline strings; Array.prototype.join db.c.insertOne({_id: 0}); db.c.aggregate([{$addFields: {y: {$function: {   body: "function(){ const a=[]; for (let i=0;i<1000;i++) a.push( 'xxxxxxxxxx' );" +         " let t=0; for (let i=0;i<20000;i++) t += a.join('').length; return t; }" ,   args: [], lang: "js" }}}}]);
    • 200
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      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. 

            Assignee:
            Mariano Shaar
            Reporter:
            Milena Ivanova
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: