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. Stack switching mechanism in a computer system

    A method and mechanism for performing an unconditional stack switch in a processor. A processor incl ...

  2. 119.WIN32窗口原理

    #include <Windows.h> //处理消息的回调函数 LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); int WIN ...

  3. 1.2 Use Cases中 Event Sourcing官网剖析(博主推荐)

    不多说,直接上干货! 一切来源于官网 http://kafka.apache.org/documentation/ Event Sourcing 事件采集 Event sourcing is a st ...

  4. 在MacOS下使用Fiddler抓包

    在MacOS下使用Fiddler抓包 有两种方式,分别是安装Mac版的Fiddler,或者是用虚拟机,安装Windows系统,在Windows系统下运行Fiddler对Mac系统中的内容进行抓包. M ...

  5. vc如何让打开的子窗口默认是最大化的

    vc如何让打开的子窗口默认是最大化的 浏览: 3554 | 更新: 2011-04-09 17:04 1 0     加入杂志加入杂志 摘要:关于vc如何让打开的子窗口默认是最大化的深入研究.   步 ...

  6. VC中画矩形框 & polyline画多点

    搞自动化会经常遇到一个问题就是记录实时的曲线,通常做法是首先将数据保存在一个记事本中,或数据库.使用VB或DELPHI可以直接调用现成的控件画图,只是控制起来不方便.所以使用VC就需要程序来控制.在网 ...

  7. 【Codeforces Round #431 (Div. 2) C】From Y to Y

    [链接]点击打开链接 [题意] 让你构造一个大小最多为10W的字符multiset. 你进行n-1次操作; 每次操作,从set中取出两个字符串,一开始单个字符被认为是字符串. 然后把它们连接在一起. ...

  8. mycat 之datanode datahost writehost readhost 区别(转)

    <?xml version="1.0"?> <!DOCTYPE mycat:schema SYSTEM "schema.dtd"> &l ...

  9. [C/C++]_[0基础]_[static_cast,reinterpret_cast,dynimic_cast的使用场景和差别]

    场景: 1. C++的对象差别于C的原因是他们能够有继承关系, 方法有重载, 覆盖关系等, 他们的对象内存数据结构因此也比較复杂. 2. 非常多情况下我们须要一个父类来存储子类的指针对象进行通用方法的 ...

  10. HTTP网络协议(四)

    确保Web安全的HTTPS HTTP存在三个比较明显的缺点: 通信使用明文(不加密),内容可能会被窃听. 不验证通信方的身份,因此有可能遭遇伪装. 无法证明报文的完整性,所以可能已遭篡改.  尽管HT ...