-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Closed
Description
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
Labels
No labels