{"action":"created","issue":{"url":"https://api.github.com/repos/bnoordhuis/node-heapdump/issues/81","repository_url":"https://api.github.com/repos/bnoordhuis/node-heapdump","labels_url":"https://api.github.com/repos/bnoordhuis/node-heapdump/issues/81/labels{/name}","comments_url":"https://api.github.com/repos/bnoordhuis/node-heapdump/issues/81/comments","events_url":"https://api.github.com/repos/bnoordhuis/node-heapdump/issues/81/events","html_url":"https://github.com/bnoordhuis/node-heapdump/issues/81","id":138286245,"number":81,"title":"Taking a heapdump take a lot of ram that is not released","user":{"login":"ChrisCinelli","id":153101,"avatar_url":"https://avatars.githubusercontent.com/u/153101?v=3","gravatar_id":"","url":"https://api.github.com/users/ChrisCinelli","html_url":"https://github.com/ChrisCinelli","followers_url":"https://api.github.com/users/ChrisCinelli/followers","following_url":"https://api.github.com/users/ChrisCinelli/following{/other_user}","gists_url":"https://api.github.com/users/ChrisCinelli/gists{/gist_id}","starred_url":"https://api.github.com/users/ChrisCinelli/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ChrisCinelli/subscriptions","organizations_url":"https://api.github.com/users/ChrisCinelli/orgs","repos_url":"https://api.github.com/users/ChrisCinelli/repos","events_url":"https://api.github.com/users/ChrisCinelli/events{/privacy}","received_events_url":"https://api.github.com/users/ChrisCinelli/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-03-03T20:18:24Z","updated_at":"2016-03-03T20:42:33Z","closed_at":null,"body":"Running on Node 4.3.1. I am looking at the monitor graph on one of machine. When I create a heapdump (through an express route). After I call the route the first time I see a spike in the memory consumption. The memory is never released.\r\n\r\n<img width=\"456\" alt=\"screen shot 2016-03-03 at 12 15 35 pm\" src=\"https://cloud.githubusercontent.com/assets/153101/13507943/dfb2170e-e139-11e5-874b-74e510b2b273.png\">\r\nThe step between 3 Mar and 4:00 is when I took the first heapdump.\r\n\r\n\r\n\r\n Is heapdump ever releasing the memory used?\r\nThis is the code:\r\n\r\n```\r\nlet heapdump = require('heapdump');\r\n\r\nserver.get('/captureHeap', (req, res, next) => {\r\n  //See https://strongloop.com/strongblog/how-to-heap-snapshots/ and https://developer.chrome.com/devtools/docs/heap-profiling\r\n    \r\n // Here we check if the user is allowed to take the snapshot.\r\n // ... \r\n // \r\n  res.header('Content-Type', 'text/html');\r\n  res.write(\"captureHeap... during this process the server will be irresponsive... <br>\");\r\n  let start = new Date();\r\n  heapdump.writeSnapshot();\r\n  fs.readdir(\".\", function(err, files){\r\n    if(err){\r\n      res.write('Error:'+err);\r\n      res.end();\r\n      return;\r\n    }\r\n\r\n    let diff = new Date() - start;\r\n    res.write('Done in '+diff+' ms!');\r\n\r\n    let hasBuild = false;\r\n    for (var i = 0; i < files.length; i++) {\r\n      if(files[i] == 'build'){\r\n        hasBuild = true;\r\n        break;\r\n      }\r\n    }\r\n\r\n    //Move the file to the public folder and create a link.\r\n    let html = \"\";\r\n    for (var i = 0; i < files.length; i++) {\r\n      let file = files[i];\r\n      if (file.match(/heapdump.*heapsnapshot/) ){\r\n        let dest = \".\"+(hasBuild ? \"/build\" : \"\")+\"/public/\"+file;\r\n        fs.rename(\"./\"+file, dest);\r\n        html += \"Download the file here: <a href='\"+file+\"'>\"+file+\"</a><br>\";\r\n      }\r\n    }\r\n\r\n    res.write(html);\r\n    res.end();\r\n  });\r\n});\r\n```"},"comment":{"url":"https://api.github.com/repos/bnoordhuis/node-heapdump/issues/comments/191953595","html_url":"https://github.com/bnoordhuis/node-heapdump/issues/81#issuecomment-191953595","issue_url":"https://api.github.com/repos/bnoordhuis/node-heapdump/issues/81","id":191953595,"user":{"login":"bnoordhuis","id":275871,"avatar_url":"https://avatars.githubusercontent.com/u/275871?v=3","gravatar_id":"","url":"https://api.github.com/users/bnoordhuis","html_url":"https://github.com/bnoordhuis","followers_url":"https://api.github.com/users/bnoordhuis/followers","following_url":"https://api.github.com/users/bnoordhuis/following{/other_user}","gists_url":"https://api.github.com/users/bnoordhuis/gists{/gist_id}","starred_url":"https://api.github.com/users/bnoordhuis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bnoordhuis/subscriptions","organizations_url":"https://api.github.com/users/bnoordhuis/orgs","repos_url":"https://api.github.com/users/bnoordhuis/repos","events_url":"https://api.github.com/users/bnoordhuis/events{/privacy}","received_events_url":"https://api.github.com/users/bnoordhuis/received_events","type":"User","site_admin":false},"created_at":"2016-03-03T20:42:33Z","updated_at":"2016-03-03T20:42:33Z","body":"It should, it calls "}}