Over a million developers have joined DZone.

Node.js Performance Garbage Collection

DZone's Guide to

Node.js Performance Garbage Collection

· Performance Zone ·
Free Resource

Sensu is an open source monitoring event pipeline. Try it today.

In another installation of useful node.js/V8 Javascript performance finds, the folks over at the StrongLoop blog  wrote about garbage collection in node.js this week. V8, with built-in garbage collection, has it's benefits and shortcomings:

...you also give up control on memory management, which could be a problem particularly for mobile applications aiming for the optimization of device resources. In particular for JavaScript, the ECMAScript specification doesn’t expose any interface to the garbage collector blocking visibility and forced GC.

Performance wise, it is a wash. In C, allocating (malloc) and freeing objects can be costly, since heap bookkeeping tends to be more complicated. With managed memory, allocation usually means just incrementing a pointer, but  you pay for it eventually when you run out of memory and the garbage collector kicks in.  The fact is that V8  uses garbage collection for better or worse.

They go on to outline how V8 divides the heap into manageable chunks and the processes through which garbage collection is enacted. Check out the post.

Sensu: workflow automation for monitoring. Learn more—download the whitepaper.


Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}