{"action":"created","issue":{"url":"https://api.github.com/repos/libusb/libusb/issues/52","labels_url":"https://api.github.com/repos/libusb/libusb/issues/52/labels{/name}","comments_url":"https://api.github.com/repos/libusb/libusb/issues/52/comments","events_url":"https://api.github.com/repos/libusb/libusb/issues/52/events","html_url":"https://github.com/libusb/libusb/pull/52","id":57094557,"number":52,"title":"darwin: fix resource leak (cached devices are never freed)","user":{"login":"parafin","id":2099800,"avatar_url":"https://avatars.githubusercontent.com/u/2099800?v=3","gravatar_id":"","url":"https://api.github.com/users/parafin","html_url":"https://github.com/parafin","followers_url":"https://api.github.com/users/parafin/followers","following_url":"https://api.github.com/users/parafin/following{/other_user}","gists_url":"https://api.github.com/users/parafin/gists{/gist_id}","starred_url":"https://api.github.com/users/parafin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/parafin/subscriptions","organizations_url":"https://api.github.com/users/parafin/orgs","repos_url":"https://api.github.com/users/parafin/repos","events_url":"https://api.github.com/users/parafin/events{/privacy}","received_events_url":"https://api.github.com/users/parafin/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":{"login":"hjelmn","id":1226817,"avatar_url":"https://avatars.githubusercontent.com/u/1226817?v=3","gravatar_id":"","url":"https://api.github.com/users/hjelmn","html_url":"https://github.com/hjelmn","followers_url":"https://api.github.com/users/hjelmn/followers","following_url":"https://api.github.com/users/hjelmn/following{/other_user}","gists_url":"https://api.github.com/users/hjelmn/gists{/gist_id}","starred_url":"https://api.github.com/users/hjelmn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hjelmn/subscriptions","organizations_url":"https://api.github.com/users/hjelmn/orgs","repos_url":"https://api.github.com/users/hjelmn/repos","events_url":"https://api.github.com/users/hjelmn/events{/privacy}","received_events_url":"https://api.github.com/users/hjelmn/received_events","type":"User","site_admin":false},"milestone":null,"comments":3,"created_at":"2015-02-09T21:44:15Z","updated_at":"2015-02-12T19:01:20Z","closed_at":"2015-02-12T18:51:27Z","pull_request":{"url":"https://api.github.com/repos/libusb/libusb/pulls/52","html_url":"https://github.com/libusb/libusb/pull/52","diff_url":"https://github.com/libusb/libusb/pull/52.diff","patch_url":"https://github.com/libusb/libusb/pull/52.patch"},"body":"For each new device (processed by hotplug code) darwin_ref_cached_device\r\nis called twice - in process_new_device and in darwin_get_cached_device\r\n(which is called from the first function). But when the device is detached\r\nonly one darwin_deref_cached_device is done - in darwin_destroy_device.\r\nSo there is inbalance between ref and deref which causes darwin_cached_devices\r\nlist to monotonically grow and consume more and more resources over time.\r\nThis commit fixes the problem by adding darwin_deref_cached_device call\r\nto darwin_devices_detached."},"comment":{"url":"https://api.github.com/repos/libusb/libusb/issues/comments/74130397","html_url":"https://github.com/libusb/libusb/pull/52#issuecomment-74130397","issue_url":"https://api.github.com/repos/libusb/libusb/issues/52","id":74130397,"user":{"login":"parafin","id":2099800,"avatar_url":"https://avatars.githubusercontent.com/u/2099800?v=3","gravatar_id":"","url":"https://api.github.com/users/parafin","html_url":"https://github.com/parafin","followers_url":"https://api.github.com/users/parafin/followers","following_url":"https://api.github.com/users/parafin/following{/other_user}","gists_url":"https://api.github.com/users/parafin/gists{/gist_id}","starred_url":"https://api.github.com/users/parafin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/parafin/subscriptions","organizations_url":"https://api.github.com/users/parafin/orgs","repos_url":"https://api.github.com/users/parafin/repos","events_url":"https://api.github.com/users/parafin/events{/privacy}","received_events_url":"https://api.github.com/users/parafin/received_events","type":"User","site_admin":false},"created_at":"2015-02-12T19:01:20Z","updated_at":"2015-02-12T19:01:20Z","body":"Well, maybe by definition it's not a leak, since there is a cleanup code which is run on library unload (program exit), but consequences are the same as if it was a real leak - there is no point in keeping around information (and particularly open handle) about disconnected device. I found this issue because there is a report that real problems arise (like long USB bus scanning time) when program using libusb runs for a long time on OS X and a lot of USB connect/disconnect events happen in that time. So it's good that you accepted the patch;)"}}