{"action":"closed","issue":{"url":"https://api.github.com/repos/sandeepmistry/node-sensortag/issues/83","repository_url":"https://api.github.com/repos/sandeepmistry/node-sensortag","labels_url":"https://api.github.com/repos/sandeepmistry/node-sensortag/issues/83/labels{/name}","comments_url":"https://api.github.com/repos/sandeepmistry/node-sensortag/issues/83/comments","events_url":"https://api.github.com/repos/sandeepmistry/node-sensortag/issues/83/events","html_url":"https://github.com/sandeepmistry/node-sensortag/issues/83","id":172303971,"number":83,"title":"Memory Leak -- Listeners not released","user":{"login":"mitron6","id":8966523,"avatar_url":"https://avatars.githubusercontent.com/u/8966523?v=3","gravatar_id":"","url":"https://api.github.com/users/mitron6","html_url":"https://github.com/mitron6","followers_url":"https://api.github.com/users/mitron6/followers","following_url":"https://api.github.com/users/mitron6/following{/other_user}","gists_url":"https://api.github.com/users/mitron6/gists{/gist_id}","starred_url":"https://api.github.com/users/mitron6/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mitron6/subscriptions","organizations_url":"https://api.github.com/users/mitron6/orgs","repos_url":"https://api.github.com/users/mitron6/repos","events_url":"https://api.github.com/users/mitron6/events{/privacy}","received_events_url":"https://api.github.com/users/mitron6/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":6,"created_at":"2016-08-21T04:31:35Z","updated_at":"2016-09-17T19:39:26Z","closed_at":"2016-09-17T19:39:26Z","body":"Repeated discoverAll/stopDiscoverAll with device advertising but not connecting fails to release a listener.  \r\n\r\nThe following code duplicates the problem on both OSX and Raspian. \r\n\r\nvar sensortag = require('sensortag');\r\n\r\nfunction onDiscover(sensor) {console.log('Found: ' + sensor.id)}\r\n\r\nvar scanning = false;\r\nvar count = 0;\r\n\r\nfunction discover() {\r\n  if (scanning) {\r\n    console.log('StopDiscoverAll\\n');\r\n    sensortag.stopDiscoverAll(onDiscover)\r\n  }\r\n scanning = true;\r\n  sensortag.discoverAll(onDiscover);\r\n  console.log(++count + '.\\ndiscoverAll');\r\n}\r\n\r\nsetInterval(discover, 2000);\r\n\r\nProduces the following output:\r\n1.\r\ndiscoverAll\r\nFound: 247189079301\r\nStopDiscoverAll\r\n\r\n2.\r\ndiscoverAll\r\nFound: 247189079301\r\nStopDiscoverAll\r\n\r\n3.\r\ndiscoverAll\r\nFound: 247189079301\r\nStopDiscoverAll\r\n\r\n4.\r\ndiscoverAll\r\nFound: 247189079301\r\nStopDiscoverAll\r\n\r\n5.\r\ndiscoverAll\r\nFound: 247189079301\r\nStopDiscoverAll\r\n\r\n6.\r\ndiscoverAll\r\nFound: 247189079301\r\nStopDiscoverAll\r\n\r\n7.\r\ndiscoverAll\r\nFound: 247189079301\r\nStopDiscoverAll\r\n\r\n8.\r\ndiscoverAll\r\nFound: 247189079301\r\nStopDiscoverAll\r\n\r\n9.\r\ndiscoverAll\r\nFound: 247189079301\r\nStopDiscoverAll\r\n\r\n10.\r\ndiscoverAll\r\nFound: 247189079301\r\nStopDiscoverAll\r\n\r\n11.\r\ndiscoverAll\r\n(node) warning: possible EventEmitter memory leak detected. 11 disconnect listeners added. Use emitter.setMaxListeners() to increase limit.\r\nTrace\r\n    at Peripheral.addListener (events.js:239:17)\r\n    at NobleDevice (/usr/src/app/node_modules/sensortag/node_modules/noble-device/lib/noble-device.js:18:20)\r\n    at new CC2650SensorTag (/usr/src/app/node_modules/sensortag/lib/cc2650.js:30:15)\r\n    at Noble.constructor.onDiscover (/usr/src/app/node_modules/sensortag/node_modules/noble-device/lib/util.js:28:22)\r\n    at emitOne (events.js:82:20)\r\n    at Noble.emit (events.js:169:7)\r\n    at Noble.onDiscover (/usr/src/app/node_modules/sensortag/node_modules/noble-device/node_modules/noble/lib/noble.js:135:10)\r\n    at emitMany (events.js:108:13)\r\n    at emit (events.js:182:7)\r\n    at NobleBindings.onDiscover (/usr/src/app/node_modules/sensortag/node_modules/noble-device/node_modules/noble/lib/hci-socket/bindings.js:169:10)"}}
{"actor":{"display_login":"sandeepmistry"}}