{"action":"created","issue":{"url":"https://api.github.com/repos/rs/SDWebImage/issues/2474","repository_url":"https://api.github.com/repos/rs/SDWebImage","labels_url":"https://api.github.com/repos/rs/SDWebImage/issues/2474/labels{/name}","comments_url":"https://api.github.com/repos/rs/SDWebImage/issues/2474/comments","events_url":"https://api.github.com/repos/rs/SDWebImage/issues/2474/events","html_url":"https://github.com/rs/SDWebImage/pull/2474","id":357901026,"node_id":"MDExOlB1bGxSZXF1ZXN0MjEzODAyOTAx","number":2474,"title":"Add autoreleasepool to release autorelease objects in advance when using GCD","user":{"login":"zhongwuzw","id":5061845,"node_id":"MDQ6VXNlcjUwNjE4NDU=","avatar_url":"https://avatars0.githubusercontent.com/u/5061845?v=4","gravatar_id":"","url":"https://api.github.com/users/zhongwuzw","html_url":"https://github.com/zhongwuzw","followers_url":"https://api.github.com/users/zhongwuzw/followers","following_url":"https://api.github.com/users/zhongwuzw/following{/other_user}","gists_url":"https://api.github.com/users/zhongwuzw/gists{/gist_id}","starred_url":"https://api.github.com/users/zhongwuzw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zhongwuzw/subscriptions","organizations_url":"https://api.github.com/users/zhongwuzw/orgs","repos_url":"https://api.github.com/users/zhongwuzw/repos","events_url":"https://api.github.com/users/zhongwuzw/events{/privacy}","received_events_url":"https://api.github.com/users/zhongwuzw/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2018-09-07T02:56:24Z","updated_at":"2018-09-07T10:33:41Z","closed_at":null,"author_association":"COLLABORATOR","pull_request":{"url":"https://api.github.com/repos/rs/SDWebImage/pulls/2474","html_url":"https://github.com/rs/SDWebImage/pull/2474","diff_url":"https://github.com/rs/SDWebImage/pull/2474.diff","patch_url":"https://github.com/rs/SDWebImage/pull/2474.patch"},"body":"\r\n\r\n### New Pull Request Checklist\r\n\r\n* [x] I have read and understood the [CONTRIBUTING guide](https://github.com/rs/SDWebImage/blob/master/.github/CONTRIBUTING.md)\r\n* [x] I have read the [Documentation](http://cocoadocs.org/docsets/SDWebImage/)\r\n* [x] I have searched for a similar pull request in the [project](https://github.com/rs/SDWebImage/pulls) and found none\r\n\r\n* [ ] I have updated this branch with the latest master to avoid conflicts (via merge from master or rebase)\r\n* [ ] I have added the required tests to prove the fix/feature I am adding\r\n* [ ] I have updated the documentation (if necessary)\r\n* [ ] I have run the tests and they pass\r\n* [ ] I have run the lint and it passes (`pod lib lint`)\r\n\r\nThis merge request fixes / reffers to the following issues: ...\r\n\r\n### Pull Request Description\r\n\r\nFixes #2427 .\r\n\r\nWe use GCD to do some progressive or decode work, it would produce some big size autorelease objects. But actually, GCD would not guarantee when to drain these objects, sometimes would leads to crash, like #2427 . So we need to add a explicitly `autoreleasepool` to  drain them timely.\r\n\r\nPS. [Apple Documents](https://developer.apple.com/library/archive/documentation/General/Conceptual/ConcurrencyProgrammingGuide/OperationQueues/OperationQueues.html#//apple_ref/doc/uid/TP40008091-CH102-SW1)\r\n> If your block creates more than a few Objective-C objects, you might want to enclose parts of your block’s code in an @autorelease block to handle the memory management for those objects. Although GCD dispatch queues have their own autorelease pools, they make no guarantees as to when those pools are drained. If your application is memory constrained, creating your own autorelease pool allows you to free up the memory for autoreleased objects at more regular intervals.\r\n"},"comment":{"url":"https://api.github.com/repos/rs/SDWebImage/issues/comments/419398145","html_url":"https://github.com/rs/SDWebImage/pull/2474#issuecomment-419398145","issue_url":"https://api.github.com/repos/rs/SDWebImage/issues/2474","id":419398145,"node_id":"MDEyOklzc3VlQ29tbWVudDQxOTM5ODE0NQ==","user":{"login":"zhongwuzw","id":5061845,"node_id":"MDQ6VXNlcjUwNjE4NDU=","avatar_url":"https://avatars0.githubusercontent.com/u/5061845?v=4","gravatar_id":"","url":"https://api.github.com/users/zhongwuzw","html_url":"https://github.com/zhongwuzw","followers_url":"https://api.github.com/users/zhongwuzw/followers","following_url":"https://api.github.com/users/zhongwuzw/following{/other_user}","gists_url":"https://api.github.com/users/zhongwuzw/gists{/gist_id}","starred_url":"https://api.github.com/users/zhongwuzw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zhongwuzw/subscriptions","organizations_url":"https://api.github.com/users/zhongwuzw/orgs","repos_url":"https://api.github.com/users/zhongwuzw/repos","events_url":"https://api.github.com/users/zhongwuzw/events{/privacy}","received_events_url":"https://api.github.com/users/zhongwuzw/received_events","type":"User","site_admin":false},"created_at":"2018-09-07T10:33:41Z","updated_at":"2018-09-07T10:33:41Z","author_association":"COLLABORATOR","body":"@dreampiggy Please see my `PR` description, you can try #2427, it 100% crashes in very little time.\r\n\r\nI don't think we need to add `autoreleasepool` in decode function, it's the problem to `GCD`, call it multiple times and maybe not release in timely. "}}
{"actor":{"display_login":"zhongwuzw"}}