Skip to content

longStackTraces memory issue #447

@Volox

Description

@Volox

Hi,
i have a memory issue using Promise.longStackTraces(). I tried to create an "infite loop" for a crawler and noticed a huge memory usage for the application; i debugged the application and found a strange behaviour.

The following code illustrates the problem:

var Promise = require( 'bluebird' );
Promise.longStackTraces();
var SIZE=1024*1024;

function crawlLoop() {
  var arr = [];
  for( var i=0; i<SIZE; i++ ) {
    arr.push( {} );
  }
  return Promise.resolve( arr ).then( crawlLoop );
}

crawlLoop();

After a few tentatives i noticed that by removing Promise.longStackTraces() the problem was solved.
Another solution is to call setImmediate in the last then of the promise like:

return Promise.resolve( arr ).then( function() { setImmediate( crawlLoop ); } );

Can someone please explain me what is wrong with the code (a part for the infinite loop)?

My configuration:
node x64 0.11.13
Windows x64
Bluebird: 2.3.11

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions