In this lesson, I introduce a memory leak into our node.js application and show you how to identify it using the Formidable nodejs-dashboard. Once identified, we will add garbage collection stats to the error console allowing us to correlate garbage collection with the increased memory usage.

Install:

npm i -D gc-profiler nodejs-dashboard
let express = require('express');
let router = express.Router();
let faker = require('faker');
let words = [];
let profiler = require('gc-profiler'); profiler.on('gc', (info) => {
console.error(info);
}); router.get('/', function(req, res, next) {
let num = Math.floor(Math.random() * ) + ;
let searchterm = faker.lorem.words(num);
let arr = searchterm.split(' ');
arr.forEach(word => {
words.push(word); // cause memory leak
});
console.log(`Generating ${num} words`);
res.send(searchterm);
}); module.exports = router;

In the code, we can use 'gc-profiler' to monitor the gb collection in order to see the memory leak in dashboard.

[Node.js] Identify memory leaks with nodejs-dashboard的更多相关文章

  1. Identify Memory Leaks in Visual CPP Applications —— VLD内存泄漏检测工具

    原文地址:http://www.codeproject.com/Articles/1045847/Identify-Memory-Leaks-in-Visual-CPP-Applications 基于 ...

  2. 学习node.js 第1篇 介绍nodejs

    Node.js是什么? Node.js是建立在谷歌Chrome的JavaScript引擎(V8引擎)的Web应用程序框架. 它的最新版本是:v0.12.7(在编写本教程时的版本).Node.js在官方 ...

  3. Node.js 笔记(一) nodejs、npm、express安装

    Windows平台下的node.js安装 直接去nodejs的官网http://nodejs.org/上下载nodejs安装程序,双击安装就可以了 测试安装是否成功: 在命令行输入 node –v 应 ...

  4. Node.js 笔记(一) nodejs、npm、express安装(转)

    转载地址:http://blog.csdn.net/haidaochen/article/details/7257655 Windows平台下的node.js安装 直接去nodejs的官网http:/ ...

  5. Node.js(daemon),tweak(debug ES)/nodejs forever,supervisor--express

    http://www.cnblogs.com/Darren_code/p/node_express.html express -e nodejs-product sudo npm install fo ...

  6. mac下命令行安装node.js及切换不同版本nodejs

    摘自: http://www.cnblogs.com/ikuyka/p/5825762.html 前提是你电脑里已经装了node.js然后才能采用以下命令(以下代码最好不要同时运行) sudo n - ...

  7. Node.js笔记(九)Nodejs与shell

    众所周知.Nodejs是单进程异步执行的.但不光是单进程,Nodejs也提供了多进程方面的支持 其创始人应该还是比較重视这一块的,最有力的证据就是child_process是Nodejs核心模块之中的 ...

  8. Node.js精进(10)——性能监控(下)

    本节会重点分析内存和进程奔溃,并且会给出相应的监控方法. 本系列所有的示例源码都已上传至Github,点击此处获取. 一.内存 虽然在 Node.js 中并不需要手动的对内存进行分配和销毁,但是在开发 ...

  9. 专门针对初学者的Node.js教程

    转载原文:http://www.csdn.net/article/2013-08-28/2816731-absolute-beginners-guide-to-nodejs Node.js的教程并不缺 ...

随机推荐

  1. 【习题 7-6 UVA - 12113】Overlapping Squares

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 先预处理出来一个正方形. 然后每次枚举新加的正方形左上角的坐标就可以. 注意覆盖的规则,控制一下就可以. 然后暴力判断是否相同. 暴 ...

  2. Redmine安装

    http://www.itnpc.com/news/web/146433249372595.html http://www.cnblogs.com/iluzhiyong/p/redmine.html ...

  3. 腾讯官网生成qq在线客服代码

    http://jingyan.baidu.com/article/e2284b2b42ce8ce2e6118ddd.html

  4. [React] Render Elements Outside the Current React Tree using Portals in React 16

    By default the React Component Tree directly maps to the DOM Tree. In some cases when you have UI el ...

  5. 用Promise对象封装JQuery的AJAX过程

    let jqPostAjaxPromise = function(param){ return new Promise(function(resolve, reject){ $.ajax({ url: ...

  6. 绝对定位等html结构,水平居中的处理方案

    1.父子结构,父relative,子absolute.子元素要水平居中:left:50%:margin-left:子元素一半的宽度.因为定位的left是按左边框开始计算.[固定问题的模块化解决]

  7. Android实践 -- 设置系统日期时间和时区

    设置系统日期时间和时区 设置系统的日期时间和时区,需要 系统权限和系统签名,android:sharedUserId="android.uid.system" 需要在manifes ...

  8. asp.net mvc 中的自定义验证(Custom Validation Attribute)

    前言

  9. python分解质因数

    将一个正整数分解质因数.例如:输入90,打印出90=2*3*3*5. # !/usr/bin/env python # -*- coding:utf-8 -*- # Author:Hiuhung Wa ...

  10. 通达OA 小飞鱼在线开发培训第一讲介绍(图文)

    培训课件的主要内容.须要參加培训的同学要注意了.课程内容以有用为主.课件仅供參考.