{"action":"created","comment":{"url":"https://api.github.com/repos/sccn/labstreaminglayer/pulls/comments/143467891","pull_request_review_id":67982947,"id":143467891,"diff_hunk":"@@ -88,12 +89,10 @@ namespace lsl {\n \t\t\t/// Create a new sample with a given timestamp and pushthrough flag.\n \t\t\t/// Only one thread may call this function for a given factory object.\n \t\t\tsample_p new_sample(double timestamp, bool pushthrough) { \n-\t\t\t\tchar * c = NULL;\n \t\t\t\tsample *result = pop_freelist();\n-\t\t\t\tif (!result){\n-\t\t\t\t\tc = new char[sample_size_];\n-\t\t\t\t\tresult = new(c) sample(fmt_,num_chans_,this);\n-\t\t\t\t\tdelete c;\n+\t\t\t\tif (!result) {\n+\t\t\t\t\tresult = new(new char[sample_size_]) sample(fmt_, num_chans_, this);","path":"LSL/liblsl/src/sample.h","position":null,"original_position":28,"commit_id":"c69fb77cf2c03b84383694588c721bc37104ca3b","original_commit_id":"c69fb77cf2c03b84383694588c721bc37104ca3b","user":{"login":"tstenner","id":920936,"avatar_url":"https://avatars2.githubusercontent.com/u/920936?v=4","gravatar_id":"","url":"https://api.github.com/users/tstenner","html_url":"https://github.com/tstenner","followers_url":"https://api.github.com/users/tstenner/followers","following_url":"https://api.github.com/users/tstenner/following{/other_user}","gists_url":"https://api.github.com/users/tstenner/gists{/gist_id}","starred_url":"https://api.github.com/users/tstenner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tstenner/subscriptions","organizations_url":"https://api.github.com/users/tstenner/orgs","repos_url":"https://api.github.com/users/tstenner/repos","events_url":"https://api.github.com/users/tstenner/events{/privacy}","received_events_url":"https://api.github.com/users/tstenner/received_events","type":"User","site_admin":false},"body":"I don't understand why we need placement new on a heap allocated char array. Maybe to keep a constant size?","created_at":"2017-10-09T13:31:12Z","updated_at":"2017-10-09T13:31:12Z","html_url":"https://github.com/sccn/labstreaminglayer/pull/236#discussion_r143467891","pull_request_url":"https://api.github.com/repos/sccn/labstreaminglayer/pulls/236","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/sccn/labstreaminglayer/pulls/comments/143467891"},"html":{"href":"https://github.com/sccn/labstreaminglayer/pull/236#discussion_r143467891"},"pull_request":{"href":"https://api.github.com/repos/sccn/labstreaminglayer/pulls/236"}}},"pull_request":{"url":"https://api.github.com/repos/sccn/labstreaminglayer/pulls/236","id":145341650,"html_url":"https://github.com/sccn/labstreaminglayer/pull/236","diff_url":"https://github.com/sccn/labstreaminglayer/pull/236.diff","patch_url":"https://github.com/sccn/labstreaminglayer/pull/236.patch","issue_url":"https://api.github.com/repos/sccn/labstreaminglayer/issues/236","number":236,"state":"open","locked":false,"title":"mem leak revised fix","user":{"login":"cboulay","id":303797,"avatar_url":"https://avatars1.githubusercontent.com/u/303797?v=4","gravatar_id":"","url":"https://api.github.com/users/cboulay","html_url":"https://github.com/cboulay","followers_url":"https://api.github.com/users/cboulay/followers","following_url":"https://api.github.com/users/cboulay/following{/other_user}","gists_url":"https://api.github.com/users/cboulay/gists{/gist_id}","starred_url":"https://api.github.com/users/cboulay/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cboulay/subscriptions","organizations_url":"https://api.github.com/users/cboulay/orgs","repos_url":"https://api.github.com/users/cboulay/repos","events_url":"https://api.github.com/users/cboulay/events{/privacy}","received_events_url":"https://api.github.com/users/cboulay/received_events","type":"User","site_admin":false},"body":"Replaces #234 \r\n\r\n>Ok. I think I got it now. This seems not to crash anything, but more testing is required. I tested it sending 8 floats at a time at 100 Hz. I don't see any reason that this wouldn't scale up to any sampling rate or any data size (within the limits of LSL) but who knows. I would like to test it at high sampling rates, with large data sizes, and with markers.\r\n\r\n>So, no. The memory profiler did show me a leak, and the above is a plug, but the underlying problem of high sampling rates is still unresolved. I think this has something to do with boost::asio. Either there is a bug in boost::asio itself that nobody till now has noticed (unlikely), or else a buffer is growing somewhere where I can't see it.\r\n\r\n>The heap memory management in LSL is fairly complicated and pointers get allocated and free in many different ways. I am going to leave the PR up for now but this is far from over.\r\n\r\n>Ok. More updates. I am pretty much stuck. There are actually two leaks. The first is detectable with deleaker and perceptible through the usual Visual Studio diagnostic tools. This is the one I plugged here: https://github.com/sccn/labstreaminglayer/commit/38e4ced06c463f520196940ab1772ba2f7c56d33\r\n\r\n>However, with this patch, an outlet can only connect to one inlet. So it seems that this inner allocation of memory is not being freed. I tried using a shared_ptr here, but that doesn't work at all.\r\n\r\n>The other issue is that in addition to this, there is a slow leak that I cannot locate. I've been through the whole pipeline until samples go behind the shadow of boost::asio in the tcp service, and as far as I can tell, everything is rock solid. Boost is never wrong, so I doubt there is a problem there. Just in case, I pinged the boost list. I also tried adding some boost::asio::io_service::work objects as per this suggestion: https://stackoverflow.com/questions/32258890/c-boost-asio-async-send-to-memory-leak but it seems to have no effect.\r\n","created_at":"2017-10-08T16:17:00Z","updated_at":"2017-10-09T13:31:12Z","closed_at":null,"merged_at":null,"merge_commit_sha":"959e4e3a8d789681d11fd2e5835c453e4a3c9f68","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/sccn/labstreaminglayer/pulls/236/commits","review_comments_url":"https://api.github.com/repos/sccn/labstreaminglayer/pulls/236/comments","review_comment_url":"https://api.github.com/repos/sccn/labstreaminglayer/pulls/comments{/number}","comments_url":"https://api.github.com/repos/sccn/labstreaminglayer/issues/236/comments","statuses_url":"https://api.github.com/repos/sccn/labstreaminglayer/statuses/c69fb77cf2c03b84383694588c721bc37104ca3b","head":{"label":"sccn:mem_leak_2nd_attempt","ref":"mem_leak_2nd_attempt","sha":"c69fb77cf2c03b84383694588c721bc37104ca3b","user":{"login":"sccn","id":3052323,"avatar_url":"https://avatars2.githubusercontent.com/u/3052323?v=4","gravatar_id":"","url":"https://api.github.com/users/sccn","html_url":"https://github.com/sccn","followers_url":"https://api.github.com/users/sccn/followers","following_url":"https://api.github.com/users/sccn/following{/other_user}","gists_url":"https://api.github.com/users/sccn/gists{/gist_id}","starred_url":"https://api.github.com/users/sccn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sccn/subscriptions","organizations_url":"https://api.github.com/users/sccn/orgs","repos_url":"https://api.github.com/users/sccn/repos","events_url":"https://api.github.com/users/sccn/events{/privacy}","received_events_url":"https://api.github.com/users/sccn/received_events","type":"Organization","site_admin":false},"repo":{"id":33388397,"name":"labstreaminglayer","full_name":"sccn/labstreaminglayer","owner":{"login":"sccn","id":3052323,"avatar_url":"https://avatars2.githubusercontent.com/u/3052323?v=4","gravatar_id":"","url":"https://api.github.com/users/sccn","html_url":"https://github.com/sccn","followers_url":"https://api.github.com/users/sccn/followers","following_url":"https://api.github.com/users/sccn/following{/other_user}","gists_url":"https://api.github.com/users/sccn/gists{/gist_id}","starred_url":"https://api.github.com/users/sccn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sccn/subscriptions","organizations_url":"https://api.github.com/users/sccn/orgs","repos_url":"https://api.github.com/users/sccn/repos","events_url":"https://api.github.com/users/sccn/events{/privacy}","received_events_url":"https://api.github.com/users/sccn/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/sccn/labstreaminglayer","description":"Multi-modal time-synched data transmission over local network","fork":false,"url":"https://api.github.com/repos/sccn/labstreaminglayer","forks_url":"https://api.github.com/repos/sccn/labstreaminglayer/forks","keys_url":"https://api.github.com/repos/sccn/labstreaminglayer/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sccn/labstreaminglayer/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sccn/labstreaminglayer/teams","hooks_url":"https://api.github.com/repos/sccn/labstreaminglayer/hooks","issue_events_url":"https://api.github.com/repos/sccn/labstreaminglayer/issues/events{/number}","events_url":"https://api.github.com/repos/sccn/labstreaminglayer/events","assignees_url":"https://api.github.com/repos/sccn/labstreaminglayer/assignees{/user}","branches_url":"https://api.github.com/repos/sccn/labstreaminglayer/branches{/branch}","tags_url":"https://api.github.com/repos/sccn/labstreaminglayer/tags","blobs_url":"https://api.github.com/repos/sccn/labstreaminglayer/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sccn/labstreaminglayer/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sccn/labstreaminglayer/git/refs{/sha}","trees_url":"https://api.github.com/repos/sccn/labstreaminglayer/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sccn/labstreaminglayer/statuses/{sha}","languages_url":"https://api.github.com/repos/sccn/labstreaminglayer/languages","stargazers_url":"https://api.github.com/repos/sccn/labstreaminglayer/stargazers","contributors_url":"https://api.github.com/repos/sccn/labstreaminglayer/contributors","subscribers_url":"https://api.github.com/repos/sccn/labstreaminglayer/subscribers","subscription_url":"https://api.github.com/repos/sccn/labstreaminglayer/subscription","commits_url":"https://api.github.com/repos/sccn/labstreaminglayer/commits{/sha}","git_commits_url":"https://api.github.com/repos/sccn/labstreaminglayer/git/commits{/sha}","comments_url":"https://api.github.com/repos/sccn/labstreaminglayer/comments{/number}","issue_comment_url":"https://api.github.com/repos/sccn/labstreaminglayer/issues/comments{/number}","contents_url":"https://api.github.com/repos/sccn/labstreaminglayer/contents/{+path}","compare_url":"https://api.github.com/repos/sccn/labstreaminglayer/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sccn/labstreaminglayer/merges","archive_url":"https://api.github.com/repos/sccn/labstreaminglayer/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sccn/labstreaminglayer/downloads","issues_url":"https://api.github.com/repos/sccn/labstreaminglayer/issues{/number}","pulls_url":"https://api.github.com/repos/sccn/labstreaminglayer/pulls{/number}","milestones_url":"https://api.github.com/repos/sccn/labstreaminglayer/milestones{/number}","notifications_url":"https://api.github.com/repos/sccn/labstreaminglayer/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sccn/labstreaminglayer/labels{/name}","releases_url":"https://api.github.com/repos/sccn/labstreaminglayer/releases{/id}","deployments_url":"https://api.github.com/repos/sccn/labstreaminglayer/deployments","created_at":"2015-04-04T00:02:05Z","updated_at":"2017-10-09T03:54:07Z","pushed_at":"2017-10-09T13:23:24Z","git_url":"git://github.com/sccn/labstreaminglayer.git","ssh_url":"git@github.com:sccn/labstreaminglayer.git","clone_url":"https://github.com/sccn/labstreaminglayer.git","svn_url":"https://github.com/sccn/labstreaminglayer","homepage":"","size":316154,"stargazers_count":136,"watchers_count":136,"language":"C++","has_issues":true,"has_projects":true,"has_downloads":false,"has_wiki":true,"has_pages":true,"forks_count":90,"mirror_url":null,"open_issues_count":102,"forks":90,"open_issues":102,"watchers":136,"default_branch":"master"}},"base":{"label":"sccn:master","ref":"master","sha":"bf10680f6d7f157d89e5d6178ce3f9bd38df739b","user":{"login":"sccn","id":3052323,"avatar_url":"https://avatars2.githubusercontent.com/u/3052323?v=4","gravatar_id":"","url":"https://api.github.com/users/sccn","html_url":"https://github.com/sccn","followers_url":"https://api.github.com/users/sccn/followers","following_url":"https://api.github.com/users/sccn/following{/other_user}","gists_url":"https://api.github.com/users/sccn/gists{/gist_id}","starred_url":"https://api.github.com/users/sccn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sccn/subscriptions","organizations_url":"https://api.github.com/users/sccn/orgs","repos_url":"https://api.github.com/users/sccn/repos","events_url":"https://api.github.com/users/sccn/events{/privacy}","received_events_url":"https://api.github.com/users/sccn/received_events","type":"Organization","site_admin":false},"repo":{"id":33388397,"name":"labstreaminglayer","full_name":"sccn/labstreaminglayer","owner":{"login":"sccn","id":3052323,"avatar_url":"https://avatars2.githubusercontent.com/u/3052323?v=4","gravatar_id":"","url":"https://api.github.com/users/sccn","html_url":"https://github.com/sccn","followers_url":"https://api.github.com/users/sccn/followers","following_url":"https://api.github.com/users/sccn/following{/other_user}","gists_url":"https://api.github.com/users/sccn/gists{/gist_id}","starred_url":"https://api.github.com/users/sccn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sccn/subscriptions","organizations_url":"https://api.github.com/users/sccn/orgs","repos_url":"https://api.github.com/users/sccn/repos","events_url":"https://api.github.com/users/sccn/events{/privacy}","received_events_url":"https://api.github.com/users/sccn/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/sccn/labstreaminglayer","description":"Multi-modal time-synched data transmission over local network","fork":false,"url":"https://api.github.com/repos/sccn/labstreaminglayer","forks_url":"https://api.github.com/repos/sccn/labstreaminglayer/forks","keys_url":"https://api.github.com/repos/sccn/labstreaminglayer/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sccn/labstreaminglayer/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sccn/labstreaminglayer/teams","hooks_url":"https://api.github.com/repos/sccn/labstreaminglayer/hooks","issue_events_url":"https://api.github.com/repos/sccn/labstreaminglayer/issues/events{/number}","events_url":"https://api.github.com/repos/sccn/labstreaminglayer/events","assignees_url":"https://api.github.com/repos/sccn/labstreaminglayer/assignees{/user}","branches_url":"https://api.github.com/repos/sccn/labstreaminglayer/branches{/branch}","tags_url":"https://api.github.com/repos/sccn/labstreaminglayer/tags","blobs_url":"https://api.github.com/repos/sccn/labstreaminglayer/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sccn/labstreaminglayer/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sccn/labstreaminglayer/git/refs{/sha}","trees_url":"https://api.github.com/repos/sccn/labstreaminglayer/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sccn/labstreaminglayer/statuses/{sha}","languages_url":"https://api.github.com/repos/sccn/labstreaminglayer/languages","stargazers_url":"https://api.github.com/repos/sccn/labstreaminglayer/stargazers","contributors_url":"https://api.github.com/repos/sccn/labstreaminglayer/contributors","subscribers_url":"https://api.github.com/repos/sccn/labstreaminglayer/subscribers","subscription_url":"https://api.github.com/repos/sccn/labstreaminglayer/subscription","commits_url":"https://api.github.com/repos/sccn/labstreaminglayer/commits{/sha}","git_commits_url":"https://api.github.com/repos/sccn/labstreaminglayer/git/commits{/sha}","comments_url":"https://api.github.com/repos/sccn/labstreaminglayer/comments{/number}","issue_comment_url":"https://api.github.com/repos/sccn/labstreaminglayer/issues/comments{/number}","contents_url":"https://api.github.com/repos/sccn/labstreaminglayer/contents/{+path}","compare_url":"https://api.github.com/repos/sccn/labstreaminglayer/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sccn/labstreaminglayer/merges","archive_url":"https://api.github.com/repos/sccn/labstreaminglayer/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sccn/labstreaminglayer/downloads","issues_url":"https://api.github.com/repos/sccn/labstreaminglayer/issues{/number}","pulls_url":"https://api.github.com/repos/sccn/labstreaminglayer/pulls{/number}","milestones_url":"https://api.github.com/repos/sccn/labstreaminglayer/milestones{/number}","notifications_url":"https://api.github.com/repos/sccn/labstreaminglayer/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sccn/labstreaminglayer/labels{/name}","releases_url":"https://api.github.com/repos/sccn/labstreaminglayer/releases{/id}","deployments_url":"https://api.github.com/repos/sccn/labstreaminglayer/deployments","created_at":"2015-04-04T00:02:05Z","updated_at":"2017-10-09T03:54:07Z","pushed_at":"2017-10-09T13:23:24Z","git_url":"git://github.com/sccn/labstreaminglayer.git","ssh_url":"git@github.com:sccn/labstreaminglayer.git","clone_url":"https://github.com/sccn/labstreaminglayer.git","svn_url":"https://github.com/sccn/labstreaminglayer","homepage":"","size":316154,"stargazers_count":136,"watchers_count":136,"language":"C++","has_issues":true,"has_projects":true,"has_downloads":false,"has_wiki":true,"has_pages":true,"forks_count":90,"mirror_url":null,"open_issues_count":102,"forks":90,"open_issues":102,"watchers":136,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/sccn/labstreaminglayer/pulls/236"},"html":{"href":"https://github.com/sccn/labstreaminglayer/pull/236"},"issue":{"href":"https://api.github.com/repos/sccn/labstreaminglayer/issues/236"},"comments":{"href":"https://api.github.com/repos/sccn/labstreaminglayer/issues/236/comments"},"review_comments":{"href":"https://api.github.com/repos/sccn/labstreaminglayer/pulls/236/comments"},"review_comment":{"href":"https://api.github.com/repos/sccn/labstreaminglayer/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/sccn/labstreaminglayer/pulls/236/commits"},"statuses":{"href":"https://api.github.com/repos/sccn/labstreaminglayer/statuses/c69fb77cf2c03b84383694588c721bc37104ca3b"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"tstenner"}}