{"action":"created","issue":{"url":"https://api.github.com/repos/ros/ros_comm/issues/661","labels_url":"https://api.github.com/repos/ros/ros_comm/issues/661/labels{/name}","comments_url":"https://api.github.com/repos/ros/ros_comm/issues/661/comments","events_url":"https://api.github.com/repos/ros/ros_comm/issues/661/events","html_url":"https://github.com/ros/ros_comm/pull/661","id":106899874,"number":661,"title":"Prevent QueuedConnection memory/thread leak","user":{"login":"mvollrath","id":1797973,"avatar_url":"https://avatars.githubusercontent.com/u/1797973?v=3","gravatar_id":"","url":"https://api.github.com/users/mvollrath","html_url":"https://github.com/mvollrath","followers_url":"https://api.github.com/users/mvollrath/followers","following_url":"https://api.github.com/users/mvollrath/following{/other_user}","gists_url":"https://api.github.com/users/mvollrath/gists{/gist_id}","starred_url":"https://api.github.com/users/mvollrath/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mvollrath/subscriptions","organizations_url":"https://api.github.com/users/mvollrath/orgs","repos_url":"https://api.github.com/users/mvollrath/repos","events_url":"https://api.github.com/users/mvollrath/events{/privacy}","received_events_url":"https://api.github.com/users/mvollrath/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":20,"created_at":"2015-09-17T02:31:05Z","updated_at":"2015-09-18T17:37:47Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/ros/ros_comm/pulls/661","html_url":"https://github.com/ros/ros_comm/pull/661","diff_url":"https://github.com/ros/ros_comm/pull/661.diff","patch_url":"https://github.com/ros/ros_comm/pull/661.patch"},"body":"Added a timeout to `QueuedConnection`'s conditional wait() to prevent indefinite hanging threads.  These threads would eventually fill the process table when started by applications like rosbridge_server, which is expected to create and destroy many pub/sub connections.\r\n\r\nThere was a cleanup callback set on `TCPROSTransport` that was supposed to `notify()` the `Condition`, but it was being overwritten by the cleanup callback of `_PublisherImpl` and `_SubscriberImpl`.\r\n\r\nSwitching from the (broken) `notify()` callback to a timeout was less efficient than turning the transport cleanup callbacks into a list, so I did that too.\r\n\r\nFixes RobotWebTools/rosbridge_suite#165"},"comment":{"url":"https://api.github.com/repos/ros/ros_comm/issues/comments/141515771","html_url":"https://github.com/ros/ros_comm/pull/661#issuecomment-141515771","issue_url":"https://api.github.com/repos/ros/ros_comm/issues/661","id":141515771,"user":{"login":"mvollrath","id":1797973,"avatar_url":"https://avatars.githubusercontent.com/u/1797973?v=3","gravatar_id":"","url":"https://api.github.com/users/mvollrath","html_url":"https://github.com/mvollrath","followers_url":"https://api.github.com/users/mvollrath/followers","following_url":"https://api.github.com/users/mvollrath/following{/other_user}","gists_url":"https://api.github.com/users/mvollrath/gists{/gist_id}","starred_url":"https://api.github.com/users/mvollrath/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mvollrath/subscriptions","organizations_url":"https://api.github.com/users/mvollrath/orgs","repos_url":"https://api.github.com/users/mvollrath/repos","events_url":"https://api.github.com/users/mvollrath/events{/privacy}","received_events_url":"https://api.github.com/users/mvollrath/received_events","type":"User","site_admin":false},"created_at":"2015-09-18T17:37:47Z","updated_at":"2015-09-18T17:37:47Z","body":"I tested this against rosbridge with the script described in https://github.com/RobotWebTools/rosbridge_suite/issues/165#issuecomment-140908182 which makes two connections to the web socket and does some pubsub.\r\n\r\nI checked two things:\r\n\r\n* `ps -eLf | grep rosbridge_websocket | wc -l` (no increase in proc tree)\r\n* adding `objgraph.show_growth()` to the `on_close()` handler ( https://github.com/RobotWebTools/rosbridge_suite/blob/0.7.13/rosbridge_server/src/rosbridge_server/websocket_handler.py#L93-L97 )\r\n\r\nOn indigo-devel, `objgraph.show_growth()` consistently shows growth in `TCPROSTransport`, `QueuedConnection`, `_PublisherImpl`, and other classes which are instance members of those.\r\n\r\nOn fix_queued_connection_leak it stabilizes and there is no consistent growth.\r\n\r\nI'll see about making a more isolated test.  What are you running?"}}