Suppose I have a very large array in memory and want to clear it after it's no longer needed. This snippet replicates the scenario:
console.log("Memory usage initial:", process.memoryUsage()); var hugeStack = [], i, obj; function longRandomString(){ return Math.random().toString(7) + Math.random().toString(7) + Math.random().toString(7) + Math.random().toString(7); } for (i = 0; i < 1000; i++) { obj = { a: longRandomString(), b: longRandomString(), c: longRandomString() }; hugeStack.push(obj); } console.log("Memory usage with full stack:", process.memoryUsage()); hugeStack = []; obj = null; delete hugeStack, obj; console.log("Memory usage with cleared stack:", process.memoryUsage()); I would expect the last memoryUsage() report to drop significantly from the 2nd one, close to the initial level - but it just keeps going up. What's the proper way to clear up this memory usage? Thanks! -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups "nodejs" group. To post to this group, send email to nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en