{"action":"created","issue":{"url":"https://api.github.com/repos/haohui/libhdfspp/issues/33","labels_url":"https://api.github.com/repos/haohui/libhdfspp/issues/33/labels{/name}","comments_url":"https://api.github.com/repos/haohui/libhdfspp/issues/33/comments","events_url":"https://api.github.com/repos/haohui/libhdfspp/issues/33/events","html_url":"https://github.com/haohui/libhdfspp/issues/33","id":73134711,"number":33,"title":"InputStream never calls RemoteBlockReader destructor","user":{"login":"jamesclampffer","id":3167412,"avatar_url":"https://avatars.githubusercontent.com/u/3167412?v=3","gravatar_id":"","url":"https://api.github.com/users/jamesclampffer","html_url":"https://github.com/jamesclampffer","followers_url":"https://api.github.com/users/jamesclampffer/followers","following_url":"https://api.github.com/users/jamesclampffer/following{/other_user}","gists_url":"https://api.github.com/users/jamesclampffer/gists{/gist_id}","starred_url":"https://api.github.com/users/jamesclampffer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jamesclampffer/subscriptions","organizations_url":"https://api.github.com/users/jamesclampffer/orgs","repos_url":"https://api.github.com/users/jamesclampffer/repos","events_url":"https://api.github.com/users/jamesclampffer/events{/privacy}","received_events_url":"https://api.github.com/users/jamesclampffer/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-05-04T21:37:05Z","updated_at":"2015-05-04T21:58:18Z","closed_at":null,"body":"RemoteBlockReader's destructor never gets called so none of the resources it holds are never freed.  The easy way of testing is to add a destructor to RemoteBlockReader:\r\n~RemoteBlockReader() {std::cerr << \"~RemoteBlockReader\" << std::endl;};\r\nand then run  inputstream_test.  No \"~RemoteBlockReader\" message will show up.\r\n\r\nFor more details I used valgrind's dynamic heap analysis tool (DHAT).  This shows that a lot of the resources the RemoteBlockReader holds on to don't get freed because they rely on RAII.  The biggest leaks are checksum_ and what looks like header_.  These leaks start getting very large when running perf_tests in my performance testing branch. "},"comment":{"url":"https://api.github.com/repos/haohui/libhdfspp/issues/comments/98860934","html_url":"https://github.com/haohui/libhdfspp/issues/33#issuecomment-98860934","issue_url":"https://api.github.com/repos/haohui/libhdfspp/issues/33","id":98860934,"user":{"login":"jamesclampffer","id":3167412,"avatar_url":"https://avatars.githubusercontent.com/u/3167412?v=3","gravatar_id":"","url":"https://api.github.com/users/jamesclampffer","html_url":"https://github.com/jamesclampffer","followers_url":"https://api.github.com/users/jamesclampffer/followers","following_url":"https://api.github.com/users/jamesclampffer/following{/other_user}","gists_url":"https://api.github.com/users/jamesclampffer/gists{/gist_id}","starred_url":"https://api.github.com/users/jamesclampffer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jamesclampffer/subscriptions","organizations_url":"https://api.github.com/users/jamesclampffer/orgs","repos_url":"https://api.github.com/users/jamesclampffer/repos","events_url":"https://api.github.com/users/jamesclampffer/events{/privacy}","received_events_url":"https://api.github.com/users/jamesclampffer/received_events","type":"User","site_admin":false},"created_at":"2015-05-04T21:58:18Z","updated_at":"2015-05-04T21:58:18Z","body":"It looks like this is due to the destructor for InputStreamImpl::AsyncPreadSome::State never being called, and that holds the RemoreBlockReader (also leaking the socket).  \r\n\r\nI'm guessing there is a cycle of shared_ptr<State> in the monad chain at the bottom of AsyncPreadSome but I haven't been able to find it yet."}}