Skip to Content
Building Scalable Apps with Redis and Node.js
book

Building Scalable Apps with Redis and Node.js

by Joshua Johanan
September 2014
Intermediate to advanced
316 pages
7h 6m
English
Packt Publishing
Content preview from Building Scalable Apps with Redis and Node.js

Taking heap snapshots

In JavaScript, a heap snapshot will have all the objects that are not going to be garbage collected. This is perfect for tracking down memory leaks. We had briefly touched on memory leaks in Chapter 6, Using Bower to Manage Our Frontend Dependencies. Here, we will create some memory leaks on both the backend and frontend to see what they look like.

First, we will create a memory leak in Node.js. Create a new file named leak.js and put the following code into it:

var agent = require('webkit-devtools-agent'); var express = require('express'); var app = express(); var http = require('http'); var server = http.createServer(app); server.setMaxListeners(1000000); app.use(express.static(__dirname + '/static')); app.get('/', function(req, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Reactive Programming with Node.js

Reactive Programming with Node.js

Fernando Doglio
Node: Up and Running

Node: Up and Running

Tom Hughes-Croucher, Mike Wilson
Learn TypeScript 3 by Building Web Applications

Learn TypeScript 3 by Building Web Applications

Sebastien Dubois, Alexis Georges

Publisher Resources

ISBN: 9781783984480Supplemental Content