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. 栅格数据AE

    转自原文 栅格数据AE 两个星期以来一直与栅格数据打交道,对AO的栅格部分应该有了一定的理解,下面是自己的一点体会,希望高手指教:-) 1.栅格数据的存储类型 栅格数据一般可以存储为ESRI GRID ...

  2. mysql新加入用户与删除用户详细操作命令

    方法1 :使用mysql root(root权限)用户登陆直接赋权也能够创建用户 /usr/bin/mysqladmin -u root password 123456 mysql -uroot -p ...

  3. Light OJ 1373 Strongly Connected Chemicals 二分匹配最大独立集

    m种阳离子 n种阴离子 然后一个m*n的矩阵 第i行第j列为1代表第i种阴离子和第j种阴离子相互吸引 0表示排斥 求在阳离子和阴离子都至少有一种的情况下 最多存在多少种离子能够共存 阴阳离子都至少须要 ...

  4. Ubuntu配置图形桌面LXDE和VNC、中文语言包、中文输入法

    Ubuntu配置图形桌面LXDE和VNC.中文语言包.中文输入法 http://www.lijiejie.com/ubuntu-vps-config-lxde-vnc/ LXDE是Ubuntu图形桌面 ...

  5. iOS Threading编程指南 官方文档翻译第一篇(序言)

    序言   Thread是能够使多个code paths 在同一个APP内并发运行的几种技术之一.虽然新的技术为并发运行提供了先进.高效的工具(例如operation 对象和GCD),但是OS X和iO ...

  6. invalid syntax 无效语法

    python用的是spyder编译器, 再出现上一行少了个括号的时候. 在下一行显示有错误.

  7. oracle主机名修改

    转自:http://www.cnblogs.com/tippoint/archive/2013/04/07/3003810.html 有的情况下,我们需要修改已经安装oracle数据库的主机名.以下是 ...

  8. spring接收对象数组实例

    JS var param= new Array(); var one= new Object; one.id = '1'; one.name= 'simba1'; param.push(one); v ...

  9. [React] Style a React component with styled-components

    In this lesson, we remove the mapping between a React component and the styles applied to it via cla ...

  10. 【z04】计算系数

    [题目链接]:http://noi.qz5z.com/viewtask.asp?id=z04 [题解] 用二项式定理可以写出下列通式 组合数可以用杨辉三角搞出来; a的x次方直接乘就好了;指数也不大. ...