{"action":"created","comment":{"url":"https://api.github.com/repos/django/django/pulls/comments/55469771","id":55469771,"diff_hunk":"@@ -26,12 +26,25 @@ def __init__(self, engine, loaders):\n     def get_contents(self, origin):\n         return origin.loader.get_contents(origin)\n \n+    def _cache_exception(self, exc):\n+        if isinstance(exc, type) and issubclass(exc, TemplateDoesNotExist):\n+            return exc\n+        elif isinstance(exc, TemplateDoesNotExist):\n+            if self.engine.debug:\n+                return exc.__class__(*exc.args, tried=exc.tried)\n+            return exc.__class__","path":"django/template/loaders/cached.py","position":10,"original_position":10,"commit_id":"20d495f2f6d6ff6083817054b88125fb99bcc14a","original_commit_id":"20d495f2f6d6ff6083817054b88125fb99bcc14a","user":{"login":"charettes","id":9293,"avatar_url":"https://avatars.githubusercontent.com/u/9293?v=3","gravatar_id":"","url":"https://api.github.com/users/charettes","html_url":"https://github.com/charettes","followers_url":"https://api.github.com/users/charettes/followers","following_url":"https://api.github.com/users/charettes/following{/other_user}","gists_url":"https://api.github.com/users/charettes/gists{/gist_id}","starred_url":"https://api.github.com/users/charettes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/charettes/subscriptions","organizations_url":"https://api.github.com/users/charettes/orgs","repos_url":"https://api.github.com/users/charettes/repos","events_url":"https://api.github.com/users/charettes/events{/privacy}","received_events_url":"https://api.github.com/users/charettes/received_events","type":"User","site_admin":false},"body":"I see, that makes sense!","created_at":"2016-03-09T04:03:37Z","updated_at":"2016-03-09T04:03:37Z","html_url":"https://github.com/django/django/pull/6259#discussion_r55469771","pull_request_url":"https://api.github.com/repos/django/django/pulls/6259","_links":{"self":{"href":"https://api.github.com/repos/django/django/pulls/comments/55469771"},"html":{"href":"https://github.com/django/django/pull/6259#discussion_r55469771"},"pull_request":{"href":"https://api.github.com/repos/django/django/pulls/6259"}}},"pull_request":{"url":"https://api.github.com/repos/django/django/pulls/6259","id":62175798,"html_url":"https://github.com/django/django/pull/6259","diff_url":"https://github.com/django/django/pull/6259.diff","patch_url":"https://github.com/django/django/pull/6259.patch","issue_url":"https://api.github.com/repos/django/django/issues/6259","number":6259,"state":"open","locked":false,"title":"Fixed #26306 -- Memory leak in cached template loader","user":{"login":"AlexHill","id":1011483,"avatar_url":"https://avatars.githubusercontent.com/u/1011483?v=3","gravatar_id":"","url":"https://api.github.com/users/AlexHill","html_url":"https://github.com/AlexHill","followers_url":"https://api.github.com/users/AlexHill/followers","following_url":"https://api.github.com/users/AlexHill/following{/other_user}","gists_url":"https://api.github.com/users/AlexHill/gists{/gist_id}","starred_url":"https://api.github.com/users/AlexHill/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AlexHill/subscriptions","organizations_url":"https://api.github.com/users/AlexHill/orgs","repos_url":"https://api.github.com/users/AlexHill/repos","events_url":"https://api.github.com/users/AlexHill/events{/privacy}","received_events_url":"https://api.github.com/users/AlexHill/received_events","type":"User","site_admin":false},"body":"This fixes two related issues in the caching template loader, a memory leak bug and a memory use regression.\r\n\r\nIn 1.8, the thing that is cached when a template isn't found is the TemplateDoesNotExist class itself. When the debug view wants to know which paths were searched while looking for the template, it consults the rendering engine again. In 1.9, that debug information is stored on an exception instance, and those exceptions are cached.\r\n\r\nThe memory leak comes from the repeated re-raising of the same cached exception, which results in references to the `TemplateResponse` for each failed request persisting deep in the exception's context/stack information. The fix is to raise a new exception each cache hit, instead of repeatedly raising the cached exception.\r\n\r\nThe memory use regression comes from the intentional caching of every checked template path for each failed template, for debug purposes. In some projects that can end up eating all your memory. This is fixed by reverting to the 1.8 behaviour – simply caching the `TemplateDoesNotExist` class – when template debugging is not enabled.\r\n","created_at":"2016-03-09T03:38:52Z","updated_at":"2016-03-09T04:03:37Z","closed_at":null,"merged_at":null,"merge_commit_sha":"19ea1dfd8fb71a2c8ce0407faf8a0b3d336ba12c","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/django/django/pulls/6259/commits","review_comments_url":"https://api.github.com/repos/django/django/pulls/6259/comments","review_comment_url":"https://api.github.com/repos/django/django/pulls/comments{/number}","comments_url":"https://api.github.com/repos/django/django/issues/6259/comments","statuses_url":"https://api.github.com/repos/django/django/statuses/20d495f2f6d6ff6083817054b88125fb99bcc14a","head":{"label":"AlexHill:template_mem_leak","ref":"template_mem_leak","sha":"20d495f2f6d6ff6083817054b88125fb99bcc14a","user":{"login":"AlexHill","id":1011483,"avatar_url":"https://avatars.githubusercontent.com/u/1011483?v=3","gravatar_id":"","url":"https://api.github.com/users/AlexHill","html_url":"https://github.com/AlexHill","followers_url":"https://api.github.com/users/AlexHill/followers","following_url":"https://api.github.com/users/AlexHill/following{/other_user}","gists_url":"https://api.github.com/users/AlexHill/gists{/gist_id}","starred_url":"https://api.github.com/users/AlexHill/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AlexHill/subscriptions","organizations_url":"https://api.github.com/users/AlexHill/orgs","repos_url":"https://api.github.com/users/AlexHill/repos","events_url":"https://api.github.com/users/AlexHill/events{/privacy}","received_events_url":"https://api.github.com/users/AlexHill/received_events","type":"User","site_admin":false},"repo":{"id":11269762,"name":"django","full_name":"AlexHill/django","owner":{"login":"AlexHill","id":1011483,"avatar_url":"https://avatars.githubusercontent.com/u/1011483?v=3","gravatar_id":"","url":"https://api.github.com/users/AlexHill","html_url":"https://github.com/AlexHill","followers_url":"https://api.github.com/users/AlexHill/followers","following_url":"https://api.github.com/users/AlexHill/following{/other_user}","gists_url":"https://api.github.com/users/AlexHill/gists{/gist_id}","starred_url":"https://api.github.com/users/AlexHill/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AlexHill/subscriptions","organizations_url":"https://api.github.com/users/AlexHill/orgs","repos_url":"https://api.github.com/users/AlexHill/repos","events_url":"https://api.github.com/users/AlexHill/events{/privacy}","received_events_url":"https://api.github.com/users/AlexHill/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/AlexHill/django","description":"The Web framework for perfectionists with deadlines.","fork":true,"url":"https://api.github.com/repos/AlexHill/django","forks_url":"https://api.github.com/repos/AlexHill/django/forks","keys_url":"https://api.github.com/repos/AlexHill/django/keys{/key_id}","collaborators_url":"https://api.github.com/repos/AlexHill/django/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/AlexHill/django/teams","hooks_url":"https://api.github.com/repos/AlexHill/django/hooks","issue_events_url":"https://api.github.com/repos/AlexHill/django/issues/events{/number}","events_url":"https://api.github.com/repos/AlexHill/django/events","assignees_url":"https://api.github.com/repos/AlexHill/django/assignees{/user}","branches_url":"https://api.github.com/repos/AlexHill/django/branches{/branch}","tags_url":"https://api.github.com/repos/AlexHill/django/tags","blobs_url":"https://api.github.com/repos/AlexHill/django/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/AlexHill/django/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/AlexHill/django/git/refs{/sha}","trees_url":"https://api.github.com/repos/AlexHill/django/git/trees{/sha}","statuses_url":"https://api.github.com/repos/AlexHill/django/statuses/{sha}","languages_url":"https://api.github.com/repos/AlexHill/django/languages","stargazers_url":"https://api.github.com/repos/AlexHill/django/stargazers","contributors_url":"https://api.github.com/repos/AlexHill/django/contributors","subscribers_url":"https://api.github.com/repos/AlexHill/django/subscribers","subscription_url":"https://api.github.com/repos/AlexHill/django/subscription","commits_url":"https://api.github.com/repos/AlexHill/django/commits{/sha}","git_commits_url":"https://api.github.com/repos/AlexHill/django/git/commits{/sha}","comments_url":"https://api.github.com/repos/AlexHill/django/comments{/number}","issue_comment_url":"https://api.github.com/repos/AlexHill/django/issues/comments{/number}","contents_url":"https://api.github.com/repos/AlexHill/django/contents/{+path}","compare_url":"https://api.github.com/repos/AlexHill/django/compare/{base}...{head}","merges_url":"https://api.github.com/repos/AlexHill/django/merges","archive_url":"https://api.github.com/repos/AlexHill/django/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/AlexHill/django/downloads","issues_url":"https://api.github.com/repos/AlexHill/django/issues{/number}","pulls_url":"https://api.github.com/repos/AlexHill/django/pulls{/number}","milestones_url":"https://api.github.com/repos/AlexHill/django/milestones{/number}","notifications_url":"https://api.github.com/repos/AlexHill/django/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/AlexHill/django/labels{/name}","releases_url":"https://api.github.com/repos/AlexHill/django/releases{/id}","deployments_url":"https://api.github.com/repos/AlexHill/django/deployments","created_at":"2013-07-09T01:24:29Z","updated_at":"2015-03-10T00:44:58Z","pushed_at":"2016-03-09T03:35:57Z","git_url":"git://github.com/AlexHill/django.git","ssh_url":"git@github.com:AlexHill/django.git","clone_url":"https://github.com/AlexHill/django.git","svn_url":"https://github.com/AlexHill/django","homepage":"http://www.djangoproject.com/","size":128016,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":false,"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":"django:stable/1.9.x","ref":"stable/1.9.x","sha":"0e80ac467293c659588769ec0587a5bf5f084b49","user":{"login":"django","id":27804,"avatar_url":"https://avatars.githubusercontent.com/u/27804?v=3","gravatar_id":"","url":"https://api.github.com/users/django","html_url":"https://github.com/django","followers_url":"https://api.github.com/users/django/followers","following_url":"https://api.github.com/users/django/following{/other_user}","gists_url":"https://api.github.com/users/django/gists{/gist_id}","starred_url":"https://api.github.com/users/django/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/django/subscriptions","organizations_url":"https://api.github.com/users/django/orgs","repos_url":"https://api.github.com/users/django/repos","events_url":"https://api.github.com/users/django/events{/privacy}","received_events_url":"https://api.github.com/users/django/received_events","type":"Organization","site_admin":false},"repo":{"id":4164482,"name":"django","full_name":"django/django","owner":{"login":"django","id":27804,"avatar_url":"https://avatars.githubusercontent.com/u/27804?v=3","gravatar_id":"","url":"https://api.github.com/users/django","html_url":"https://github.com/django","followers_url":"https://api.github.com/users/django/followers","following_url":"https://api.github.com/users/django/following{/other_user}","gists_url":"https://api.github.com/users/django/gists{/gist_id}","starred_url":"https://api.github.com/users/django/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/django/subscriptions","organizations_url":"https://api.github.com/users/django/orgs","repos_url":"https://api.github.com/users/django/repos","events_url":"https://api.github.com/users/django/events{/privacy}","received_events_url":"https://api.github.com/users/django/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/django/django","description":"The Web framework for perfectionists with deadlines.","fork":false,"url":"https://api.github.com/repos/django/django","forks_url":"https://api.github.com/repos/django/django/forks","keys_url":"https://api.github.com/repos/django/django/keys{/key_id}","collaborators_url":"https://api.github.com/repos/django/django/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/django/django/teams","hooks_url":"https://api.github.com/repos/django/django/hooks","issue_events_url":"https://api.github.com/repos/django/django/issues/events{/number}","events_url":"https://api.github.com/repos/django/django/events","assignees_url":"https://api.github.com/repos/django/django/assignees{/user}","branches_url":"https://api.github.com/repos/django/django/branches{/branch}","tags_url":"https://api.github.com/repos/django/django/tags","blobs_url":"https://api.github.com/repos/django/django/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/django/django/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/django/django/git/refs{/sha}","trees_url":"https://api.github.com/repos/django/django/git/trees{/sha}","statuses_url":"https://api.github.com/repos/django/django/statuses/{sha}","languages_url":"https://api.github.com/repos/django/django/languages","stargazers_url":"https://api.github.com/repos/django/django/stargazers","contributors_url":"https://api.github.com/repos/django/django/contributors","subscribers_url":"https://api.github.com/repos/django/django/subscribers","subscription_url":"https://api.github.com/repos/django/django/subscription","commits_url":"https://api.github.com/repos/django/django/commits{/sha}","git_commits_url":"https://api.github.com/repos/django/django/git/commits{/sha}","comments_url":"https://api.github.com/repos/django/django/comments{/number}","issue_comment_url":"https://api.github.com/repos/django/django/issues/comments{/number}","contents_url":"https://api.github.com/repos/django/django/contents/{+path}","compare_url":"https://api.github.com/repos/django/django/compare/{base}...{head}","merges_url":"https://api.github.com/repos/django/django/merges","archive_url":"https://api.github.com/repos/django/django/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/django/django/downloads","issues_url":"https://api.github.com/repos/django/django/issues{/number}","pulls_url":"https://api.github.com/repos/django/django/pulls{/number}","milestones_url":"https://api.github.com/repos/django/django/milestones{/number}","notifications_url":"https://api.github.com/repos/django/django/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/django/django/labels{/name}","releases_url":"https://api.github.com/repos/django/django/releases{/id}","deployments_url":"https://api.github.com/repos/django/django/deployments","created_at":"2012-04-28T02:47:18Z","updated_at":"2016-03-09T02:53:13Z","pushed_at":"2016-03-09T03:58:16Z","git_url":"git://github.com/django/django.git","ssh_url":"git@github.com:django/django.git","clone_url":"https://github.com/django/django.git","svn_url":"https://github.com/django/django","homepage":"https://www.djangoproject.com/","size":183209,"stargazers_count":18405,"watchers_count":18405,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":7468,"mirror_url":null,"open_issues_count":78,"forks":7468,"open_issues":78,"watchers":18405,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/django/django/pulls/6259"},"html":{"href":"https://github.com/django/django/pull/6259"},"issue":{"href":"https://api.github.com/repos/django/django/issues/6259"},"comments":{"href":"https://api.github.com/repos/django/django/issues/6259/comments"},"review_comments":{"href":"https://api.github.com/repos/django/django/pulls/6259/comments"},"review_comment":{"href":"https://api.github.com/repos/django/django/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/django/django/pulls/6259/commits"},"statuses":{"href":"https://api.github.com/repos/django/django/statuses/20d495f2f6d6ff6083817054b88125fb99bcc14a"}}}}