{"action":"created","issue":{"url":"https://api.github.com/repos/siddontang/go-mysql/issues/18","labels_url":"https://api.github.com/repos/siddontang/go-mysql/issues/18/labels{/name}","comments_url":"https://api.github.com/repos/siddontang/go-mysql/issues/18/comments","events_url":"https://api.github.com/repos/siddontang/go-mysql/issues/18/events","html_url":"https://github.com/siddontang/go-mysql/pull/18","id":114571416,"number":18,"title":"set timeout to 1s to avoid memory leak","user":{"login":"windrainw","id":11924560,"avatar_url":"https://avatars.githubusercontent.com/u/11924560?v=3","gravatar_id":"","url":"https://api.github.com/users/windrainw","html_url":"https://github.com/windrainw","followers_url":"https://api.github.com/users/windrainw/followers","following_url":"https://api.github.com/users/windrainw/following{/other_user}","gists_url":"https://api.github.com/users/windrainw/gists{/gist_id}","starred_url":"https://api.github.com/users/windrainw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/windrainw/subscriptions","organizations_url":"https://api.github.com/users/windrainw/orgs","repos_url":"https://api.github.com/users/windrainw/repos","events_url":"https://api.github.com/users/windrainw/events{/privacy}","received_events_url":"https://api.github.com/users/windrainw/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-11-02T10:53:45Z","updated_at":"2015-11-03T00:31:46Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/siddontang/go-mysql/pulls/18","html_url":"https://github.com/siddontang/go-mysql/pull/18","diff_url":"https://github.com/siddontang/go-mysql/pull/18.diff","patch_url":"https://github.com/siddontang/go-mysql/pull/18.patch"},"body":"I use replication, when use GetEvent to sync from master, the memory usage grow rapidly. the function \r\nGetEventTimeout use select to get Events from master and use time.After to set timeout, but the two chennel in different goroutine, when the sync channel return, the time.After channel continue to run, so the memory can't be released.\r\n\r\nset timeout to 1s， make sure not used too much memory, after 1s, all used memory by time.After will be\r\ncollect by garbage collector"},"comment":{"url":"https://api.github.com/repos/siddontang/go-mysql/issues/comments/153203640","html_url":"https://github.com/siddontang/go-mysql/pull/18#issuecomment-153203640","issue_url":"https://api.github.com/repos/siddontang/go-mysql/issues/18","id":153203640,"user":{"login":"siddontang","id":1080370,"avatar_url":"https://avatars.githubusercontent.com/u/1080370?v=3","gravatar_id":"","url":"https://api.github.com/users/siddontang","html_url":"https://github.com/siddontang","followers_url":"https://api.github.com/users/siddontang/followers","following_url":"https://api.github.com/users/siddontang/following{/other_user}","gists_url":"https://api.github.com/users/siddontang/gists{/gist_id}","starred_url":"https://api.github.com/users/siddontang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/siddontang/subscriptions","organizations_url":"https://api.github.com/users/siddontang/orgs","repos_url":"https://api.github.com/users/siddontang/repos","events_url":"https://api.github.com/users/siddontang/events{/privacy}","received_events_url":"https://api.github.com/users/siddontang/received_events","type":"User","site_admin":false},"created_at":"2015-11-03T00:31:46Z","updated_at":"2015-11-03T00:31:46Z","body":"Thanks @windrainw \r\nwhy I want to use so large time here is to wait forever, if only 1s, the GetEvent will return error when we don't have any binlog, but later if we have again, we can't read it anymore. \r\n\r\nSo if the timer causes memory problem, we can fix it with not using timer, e.g, \r\n```\r\nselect {\r\n\tcase c := <-s.ch:\r\n\t\treturn c, nil\r\n\tcase s.err = <-s.ech:\r\n\t\treturn nil, s.err\r\n}\r\n```\r\n\r\nCan you help me fix it and update the PR again? "}}