File tree Expand file tree Collapse file tree 7 files changed +22
-2
lines changed Expand file tree Collapse file tree 7 files changed +22
-2
lines changed Original file line number Diff line number Diff line change 1919 "mongodb" : " ^3.1.0" ,
2020 "mongoose" : " ^5.1.7" ,
2121 "node" : " ^10.5.0" ,
22+ "node-memwatch" : " ^1.0.1" ,
2223 "nodemon" : " ^1.18.8" ,
2324 "passport" : " ^0.4.0" ,
2425 "passport-facebook" : " ^2.1.1" ,
Original file line number Diff line number Diff line change @@ -13,6 +13,9 @@ const secret=require('./config/credential.js');
1313const notification = require ( './schema/notification.js' ) ;
1414const indexRoutes = require ( './routes/index.routes' ) ;
1515const facebook = require ( './config/facebook.js' ) ;
16+ var memwatch = require ( 'node-memwatch' ) ;
17+ //Snapshot at start
18+ var hd = new memwatch . HeapDiff ( ) ;
1619
1720mongoose . connect ( secret . database , function ( ) {
1821 console . log ( 'connected' ) ;
@@ -32,8 +35,24 @@ app.use(passport.initialize());
3235app . use ( passport . session ( ) ) ;
3336
3437app . use ( indexRoutes ) ;
35-
36-
38+ //Snapshot after routing
39+ var diff = hd . end ( ) ;
40+ //Diff between both snapshots
41+ console . log ( diff )
42+ //checking for leak in memory
43+ memwatch . on ( 'leak' , ( info ) => {
44+ for ( x in info )
45+ {
46+ console . log ( x + ':' + info [ x ] ) ;
47+ }
48+ } ) ;
49+ //Stats of memory leakage
50+ memwatch . on ( 'stats' , ( info ) => {
51+ for ( x in info )
52+ {
53+ console . log ( x + ':' + info [ x ] ) ;
54+ }
55+ } ) ;
3756
3857
3958var ser = app . listen ( 3000 , function ( ) {
You can’t perform that action at this time.
0 commit comments