{"action":"created","comment":{"url":"https://api.github.com/repos/xitu/gold-miner/pulls/comments/90770302","pull_request_review_id":11288259,"id":90770302,"diff_hunk":"@@ -97,20 +97,20 @@ So how can prevent this problem from ever happening again? Let´s explain the ot\n         }\n         }\n \n-Note a main difference now: the Activity within the inner class is now referenced as follows:\n+现在注意一个主要区别：Activity 是这样被内部类引用的：\n \n     private WeakReference mainActivity;\n \n-What will happen here? When the Activity stops existing, since it is hold through the means of a WeakReference, it can be collected. Therefore no memory leaks will happen.\n+这样做有什么差别呢？ 当 Activity 不存在时，由于它是被 WeakReference 持有的，可以被收集。 因此，不会发生内存泄漏。\n \n-> **Side note:** now that you hopefully understand what WeakReferences are a little bit better, you will find useful the class WeakHashMap. It works exactly as a HashMap, except that the keys (key, not values) are referred to using WeakReferences. This makes them very useful to implement entities such as caches.\n+> **旁注:** 如果你现在对 WeakReferences 有预期的更好的了解，你会发现类 WeakHashMap 是很有用的。 它完全就是一个 HashMap，除了使用 WeakReferences 引用键（键，而不是值）。 这使得它们对于实现诸如高速缓存之类的实体非常有用。\n \n-We have mentioned however a couple of references more. Let´s see where they are useful, and how we can benefit of them:\n+我们提到过更多的引用类型。 让我们看看他们在什么地方有用，以及我们如何能从中受益：\n \n-**SoftReference**: think of a _SoftReference_ as a stronger _WeakReference_. Whereas a _WeakReference_ will be collected immediately, a _SoftReference_ will beg to the GC to stay in memory unless there is no other option. The [Garbage Collector algorithms](https://plumbr.eu/handbook/garbage-collection-algorithms-implementations) are really thrilling and something you can dive in for hours and hours without getting tired. But basically, they say _“I will always reclaim the WeakReference. If the object is a SoftReference, I will decide what to do based on the ecosystem conditions”_. This makes a _SoftReference_ very useful for the implementation of a cache: as long as the memory is plenty, we do not have to worry of manually removing objects. If you want to see an example in action, you can check [this example](http://peters-andoird-blog.blogspot.de/2012/05/softreference-cache.html) of a cache implemented with _SoftReference_.\n+**SoftReference**: **SoftReference** 可以作为一个引用强度更强的 **WeakReference**。在 **WeakReference** 将被立即回收的情形下， **SoftReference** 会向 GC 请求留在内存中，除非没有其他选项（否则是不会回收 SoftReference 引用的对象）。[ 垃圾回收算法 ](https://plumbr.eu/handbook/garbage-collection-algorithms-implementations)真的很有意思，你可以几个小时内沉醉于研究它，而不会感到疲惫。但大体上，垃圾回收会这么解说“我会永远收回 WeakReference。 如果对象是 SoftReference，我将基于生态系统条件决定是否回收。” 这使得 **SoftReference** 对于实现缓存非常有用：只要内存足够，我们就不必担心手动删除对象。 如果你想看实际中的例子，你可以查看[这个例子](http://peters-andoird-blog.blogspot.de/2012/05/softreference-cache.html)，用 **SoftReference** 实现的缓存。","path":"TODO/finally-understanding-how-references-work-in-android-and-java.md","position":99,"original_position":99,"commit_id":"12bd697356a437feeee17c5a9c1035d5513245bf","original_commit_id":"12bd697356a437feeee17c5a9c1035d5513245bf","user":{"login":"phxnirvana","id":1379562,"avatar_url":"https://avatars.githubusercontent.com/u/1379562?v=3","gravatar_id":"","url":"https://api.github.com/users/phxnirvana","html_url":"https://github.com/phxnirvana","followers_url":"https://api.github.com/users/phxnirvana/followers","following_url":"https://api.github.com/users/phxnirvana/following{/other_user}","gists_url":"https://api.github.com/users/phxnirvana/gists{/gist_id}","starred_url":"https://api.github.com/users/phxnirvana/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/phxnirvana/subscriptions","organizations_url":"https://api.github.com/users/phxnirvana/orgs","repos_url":"https://api.github.com/users/phxnirvana/repos","events_url":"https://api.github.com/users/phxnirvana/events{/privacy}","received_events_url":"https://api.github.com/users/phxnirvana/received_events","type":"User","site_admin":false},"body":"SoftReference这边上文写的是Strong reference，标题的形式要不要统一一下","created_at":"2016-12-04T04:16:59Z","updated_at":"2016-12-04T04:22:06Z","html_url":"https://github.com/xitu/gold-miner/pull/1012#discussion_r90770302","pull_request_url":"https://api.github.com/repos/xitu/gold-miner/pulls/1012","_links":{"self":{"href":"https://api.github.com/repos/xitu/gold-miner/pulls/comments/90770302"},"html":{"href":"https://github.com/xitu/gold-miner/pull/1012#discussion_r90770302"},"pull_request":{"href":"https://api.github.com/repos/xitu/gold-miner/pulls/1012"}}},"pull_request":{"url":"https://api.github.com/repos/xitu/gold-miner/pulls/1012","id":96274097,"html_url":"https://github.com/xitu/gold-miner/pull/1012","diff_url":"https://github.com/xitu/gold-miner/pull/1012.diff","patch_url":"https://github.com/xitu/gold-miner/pull/1012.patch","issue_url":"https://api.github.com/repos/xitu/gold-miner/issues/1012","number":1012,"state":"open","locked":false,"title":"彻底理解引用在 Android 和 Java 中的工作原理","user":{"login":"jacksonke","id":4094461,"avatar_url":"https://avatars.githubusercontent.com/u/4094461?v=3","gravatar_id":"","url":"https://api.github.com/users/jacksonke","html_url":"https://github.com/jacksonke","followers_url":"https://api.github.com/users/jacksonke/followers","following_url":"https://api.github.com/users/jacksonke/following{/other_user}","gists_url":"https://api.github.com/users/jacksonke/gists{/gist_id}","starred_url":"https://api.github.com/users/jacksonke/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jacksonke/subscriptions","organizations_url":"https://api.github.com/users/jacksonke/orgs","repos_url":"https://api.github.com/users/jacksonke/repos","events_url":"https://api.github.com/users/jacksonke/events{/privacy}","received_events_url":"https://api.github.com/users/jacksonke/received_events","type":"User","site_admin":false},"body":"完成 @sqrthree ","created_at":"2016-12-02T12:47:53Z","updated_at":"2016-12-04T04:22:06Z","closed_at":null,"merged_at":null,"merge_commit_sha":"730896d5d6032c2be46f5addd102d1a792d3b37e","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/xitu/gold-miner/pulls/1012/commits","review_comments_url":"https://api.github.com/repos/xitu/gold-miner/pulls/1012/comments","review_comment_url":"https://api.github.com/repos/xitu/gold-miner/pulls/comments{/number}","comments_url":"https://api.github.com/repos/xitu/gold-miner/issues/1012/comments","statuses_url":"https://api.github.com/repos/xitu/gold-miner/statuses/12bd697356a437feeee17c5a9c1035d5513245bf","head":{"label":"jacksonke:translate","ref":"translate","sha":"12bd697356a437feeee17c5a9c1035d5513245bf","user":{"login":"jacksonke","id":4094461,"avatar_url":"https://avatars.githubusercontent.com/u/4094461?v=3","gravatar_id":"","url":"https://api.github.com/users/jacksonke","html_url":"https://github.com/jacksonke","followers_url":"https://api.github.com/users/jacksonke/followers","following_url":"https://api.github.com/users/jacksonke/following{/other_user}","gists_url":"https://api.github.com/users/jacksonke/gists{/gist_id}","starred_url":"https://api.github.com/users/jacksonke/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jacksonke/subscriptions","organizations_url":"https://api.github.com/users/jacksonke/orgs","repos_url":"https://api.github.com/users/jacksonke/repos","events_url":"https://api.github.com/users/jacksonke/events{/privacy}","received_events_url":"https://api.github.com/users/jacksonke/received_events","type":"User","site_admin":false},"repo":{"id":71466748,"name":"gold-miner","full_name":"jacksonke/gold-miner","owner":{"login":"jacksonke","id":4094461,"avatar_url":"https://avatars.githubusercontent.com/u/4094461?v=3","gravatar_id":"","url":"https://api.github.com/users/jacksonke","html_url":"https://github.com/jacksonke","followers_url":"https://api.github.com/users/jacksonke/followers","following_url":"https://api.github.com/users/jacksonke/following{/other_user}","gists_url":"https://api.github.com/users/jacksonke/gists{/gist_id}","starred_url":"https://api.github.com/users/jacksonke/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jacksonke/subscriptions","organizations_url":"https://api.github.com/users/jacksonke/orgs","repos_url":"https://api.github.com/users/jacksonke/repos","events_url":"https://api.github.com/users/jacksonke/events{/privacy}","received_events_url":"https://api.github.com/users/jacksonke/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jacksonke/gold-miner","description":"掘金翻译计划，翻译掘金上优质的英文文章","fork":true,"url":"https://api.github.com/repos/jacksonke/gold-miner","forks_url":"https://api.github.com/repos/jacksonke/gold-miner/forks","keys_url":"https://api.github.com/repos/jacksonke/gold-miner/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jacksonke/gold-miner/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jacksonke/gold-miner/teams","hooks_url":"https://api.github.com/repos/jacksonke/gold-miner/hooks","issue_events_url":"https://api.github.com/repos/jacksonke/gold-miner/issues/events{/number}","events_url":"https://api.github.com/repos/jacksonke/gold-miner/events","assignees_url":"https://api.github.com/repos/jacksonke/gold-miner/assignees{/user}","branches_url":"https://api.github.com/repos/jacksonke/gold-miner/branches{/branch}","tags_url":"https://api.github.com/repos/jacksonke/gold-miner/tags","blobs_url":"https://api.github.com/repos/jacksonke/gold-miner/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jacksonke/gold-miner/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jacksonke/gold-miner/git/refs{/sha}","trees_url":"https://api.github.com/repos/jacksonke/gold-miner/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jacksonke/gold-miner/statuses/{sha}","languages_url":"https://api.github.com/repos/jacksonke/gold-miner/languages","stargazers_url":"https://api.github.com/repos/jacksonke/gold-miner/stargazers","contributors_url":"https://api.github.com/repos/jacksonke/gold-miner/contributors","subscribers_url":"https://api.github.com/repos/jacksonke/gold-miner/subscribers","subscription_url":"https://api.github.com/repos/jacksonke/gold-miner/subscription","commits_url":"https://api.github.com/repos/jacksonke/gold-miner/commits{/sha}","git_commits_url":"https://api.github.com/repos/jacksonke/gold-miner/git/commits{/sha}","comments_url":"https://api.github.com/repos/jacksonke/gold-miner/comments{/number}","issue_comment_url":"https://api.github.com/repos/jacksonke/gold-miner/issues/comments{/number}","contents_url":"https://api.github.com/repos/jacksonke/gold-miner/contents/{+path}","compare_url":"https://api.github.com/repos/jacksonke/gold-miner/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jacksonke/gold-miner/merges","archive_url":"https://api.github.com/repos/jacksonke/gold-miner/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jacksonke/gold-miner/downloads","issues_url":"https://api.github.com/repos/jacksonke/gold-miner/issues{/number}","pulls_url":"https://api.github.com/repos/jacksonke/gold-miner/pulls{/number}","milestones_url":"https://api.github.com/repos/jacksonke/gold-miner/milestones{/number}","notifications_url":"https://api.github.com/repos/jacksonke/gold-miner/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jacksonke/gold-miner/labels{/name}","releases_url":"https://api.github.com/repos/jacksonke/gold-miner/releases{/id}","deployments_url":"https://api.github.com/repos/jacksonke/gold-miner/deployments","created_at":"2016-10-20T13:37:16Z","updated_at":"2016-10-20T13:18:23Z","pushed_at":"2016-12-02T12:42:12Z","git_url":"git://github.com/jacksonke/gold-miner.git","ssh_url":"git@github.com:jacksonke/gold-miner.git","clone_url":"https://github.com/jacksonke/gold-miner.git","svn_url":"https://github.com/jacksonke/gold-miner","homepage":"http://gold.xitu.io","size":16994,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"xitu:master","ref":"master","sha":"1809875dfb92780ad758ac7aecbb5e1e6ea4b72c","user":{"login":"xitu","id":10482599,"avatar_url":"https://avatars.githubusercontent.com/u/10482599?v=3","gravatar_id":"","url":"https://api.github.com/users/xitu","html_url":"https://github.com/xitu","followers_url":"https://api.github.com/users/xitu/followers","following_url":"https://api.github.com/users/xitu/following{/other_user}","gists_url":"https://api.github.com/users/xitu/gists{/gist_id}","starred_url":"https://api.github.com/users/xitu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xitu/subscriptions","organizations_url":"https://api.github.com/users/xitu/orgs","repos_url":"https://api.github.com/users/xitu/repos","events_url":"https://api.github.com/users/xitu/events{/privacy}","received_events_url":"https://api.github.com/users/xitu/received_events","type":"Organization","site_admin":false},"repo":{"id":45512989,"name":"gold-miner","full_name":"xitu/gold-miner","owner":{"login":"xitu","id":10482599,"avatar_url":"https://avatars.githubusercontent.com/u/10482599?v=3","gravatar_id":"","url":"https://api.github.com/users/xitu","html_url":"https://github.com/xitu","followers_url":"https://api.github.com/users/xitu/followers","following_url":"https://api.github.com/users/xitu/following{/other_user}","gists_url":"https://api.github.com/users/xitu/gists{/gist_id}","starred_url":"https://api.github.com/users/xitu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xitu/subscriptions","organizations_url":"https://api.github.com/users/xitu/orgs","repos_url":"https://api.github.com/users/xitu/repos","events_url":"https://api.github.com/users/xitu/events{/privacy}","received_events_url":"https://api.github.com/users/xitu/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/xitu/gold-miner","description":"掘金翻译计划，翻译掘金上优质的英文文章","fork":false,"url":"https://api.github.com/repos/xitu/gold-miner","forks_url":"https://api.github.com/repos/xitu/gold-miner/forks","keys_url":"https://api.github.com/repos/xitu/gold-miner/keys{/key_id}","collaborators_url":"https://api.github.com/repos/xitu/gold-miner/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/xitu/gold-miner/teams","hooks_url":"https://api.github.com/repos/xitu/gold-miner/hooks","issue_events_url":"https://api.github.com/repos/xitu/gold-miner/issues/events{/number}","events_url":"https://api.github.com/repos/xitu/gold-miner/events","assignees_url":"https://api.github.com/repos/xitu/gold-miner/assignees{/user}","branches_url":"https://api.github.com/repos/xitu/gold-miner/branches{/branch}","tags_url":"https://api.github.com/repos/xitu/gold-miner/tags","blobs_url":"https://api.github.com/repos/xitu/gold-miner/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/xitu/gold-miner/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/xitu/gold-miner/git/refs{/sha}","trees_url":"https://api.github.com/repos/xitu/gold-miner/git/trees{/sha}","statuses_url":"https://api.github.com/repos/xitu/gold-miner/statuses/{sha}","languages_url":"https://api.github.com/repos/xitu/gold-miner/languages","stargazers_url":"https://api.github.com/repos/xitu/gold-miner/stargazers","contributors_url":"https://api.github.com/repos/xitu/gold-miner/contributors","subscribers_url":"https://api.github.com/repos/xitu/gold-miner/subscribers","subscription_url":"https://api.github.com/repos/xitu/gold-miner/subscription","commits_url":"https://api.github.com/repos/xitu/gold-miner/commits{/sha}","git_commits_url":"https://api.github.com/repos/xitu/gold-miner/git/commits{/sha}","comments_url":"https://api.github.com/repos/xitu/gold-miner/comments{/number}","issue_comment_url":"https://api.github.com/repos/xitu/gold-miner/issues/comments{/number}","contents_url":"https://api.github.com/repos/xitu/gold-miner/contents/{+path}","compare_url":"https://api.github.com/repos/xitu/gold-miner/compare/{base}...{head}","merges_url":"https://api.github.com/repos/xitu/gold-miner/merges","archive_url":"https://api.github.com/repos/xitu/gold-miner/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/xitu/gold-miner/downloads","issues_url":"https://api.github.com/repos/xitu/gold-miner/issues{/number}","pulls_url":"https://api.github.com/repos/xitu/gold-miner/pulls{/number}","milestones_url":"https://api.github.com/repos/xitu/gold-miner/milestones{/number}","notifications_url":"https://api.github.com/repos/xitu/gold-miner/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/xitu/gold-miner/labels{/name}","releases_url":"https://api.github.com/repos/xitu/gold-miner/releases{/id}","deployments_url":"https://api.github.com/repos/xitu/gold-miner/deployments","created_at":"2015-11-04T03:29:13Z","updated_at":"2016-12-04T04:10:34Z","pushed_at":"2016-12-03T11:52:03Z","git_url":"git://github.com/xitu/gold-miner.git","ssh_url":"git@github.com:xitu/gold-miner.git","clone_url":"https://github.com/xitu/gold-miner.git","svn_url":"https://github.com/xitu/gold-miner","homepage":"http://gold.xitu.io","size":17968,"stargazers_count":5315,"watchers_count":5315,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":989,"mirror_url":null,"open_issues_count":30,"forks":989,"open_issues":30,"watchers":5315,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/xitu/gold-miner/pulls/1012"},"html":{"href":"https://github.com/xitu/gold-miner/pull/1012"},"issue":{"href":"https://api.github.com/repos/xitu/gold-miner/issues/1012"},"comments":{"href":"https://api.github.com/repos/xitu/gold-miner/issues/1012/comments"},"review_comments":{"href":"https://api.github.com/repos/xitu/gold-miner/pulls/1012/comments"},"review_comment":{"href":"https://api.github.com/repos/xitu/gold-miner/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/xitu/gold-miner/pulls/1012/commits"},"statuses":{"href":"https://api.github.com/repos/xitu/gold-miner/statuses/12bd697356a437feeee17c5a9c1035d5513245bf"}}}}
{"actor":{"display_login":"phxnirvana"}}