{"action":"created","issue":{"url":"https://api.github.com/repos/ruby-hyperloop/hyper-react/issues/192","repository_url":"https://api.github.com/repos/ruby-hyperloop/hyper-react","labels_url":"https://api.github.com/repos/ruby-hyperloop/hyper-react/issues/192/labels{/name}","comments_url":"https://api.github.com/repos/ruby-hyperloop/hyper-react/issues/192/comments","events_url":"https://api.github.com/repos/ruby-hyperloop/hyper-react/issues/192/events","html_url":"https://github.com/ruby-hyperloop/hyper-react/issues/192","id":192667904,"number":192,"title":"memory leak in RenderingContext","user":{"login":"catmando","id":63146,"avatar_url":"https://avatars.githubusercontent.com/u/63146?v=3","gravatar_id":"","url":"https://api.github.com/users/catmando","html_url":"https://github.com/catmando","followers_url":"https://api.github.com/users/catmando/followers","following_url":"https://api.github.com/users/catmando/following{/other_user}","gists_url":"https://api.github.com/users/catmando/gists{/gist_id}","starred_url":"https://api.github.com/users/catmando/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/catmando/subscriptions","organizations_url":"https://api.github.com/users/catmando/orgs","repos_url":"https://api.github.com/users/catmando/repos","events_url":"https://api.github.com/users/catmando/events{/privacy}","received_events_url":"https://api.github.com/users/catmando/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-11-30T20:16:56Z","updated_at":"2016-11-30T23:21:56Z","closed_at":null,"body":"`RenderingContext.render` builds a buffer of rendered elements.  For example:\r\n```ruby\r\nDIV do\r\n  SPAN { 'span 1'}; SPAN { 'span 2' }; SPAN { 'span 3' }\r\nend\r\n```\r\nrendering the DIV adds the three SPANs to the DIVs rendering buffer.\r\nAs each render completes the buffer is packed up as a the children of the element being rendered, and the newly rendered element is pushed onto the *parents* buffer... \r\nSo we have a stack of these buffers.\r\n\r\nThe problem is nobody ever clears the top most rendering buffer, so after each rendering cycle all of the top most renders children remain in the buffer, and the buffer just gets longer and longer.\r\n\r\nThere is a bunch of complications between how the buffer is managed to allow for nodes to be pulled from the buffer, etc, so the fix that I propose is kind of ugly:  \r\n\r\nJust use a class instance variable to detect if its an outer most render, and if it is, then reset the buffer in the ensure block.\r\n"},"comment":{"url":"https://api.github.com/repos/ruby-hyperloop/hyper-react/issues/comments/264028667","html_url":"https://github.com/ruby-hyperloop/hyper-react/issues/192#issuecomment-264028667","issue_url":"https://api.github.com/repos/ruby-hyperloop/hyper-react/issues/192","id":264028667,"user":{"login":"catmando","id":63146,"avatar_url":"https://avatars.githubusercontent.com/u/63146?v=3","gravatar_id":"","url":"https://api.github.com/users/catmando","html_url":"https://github.com/catmando","followers_url":"https://api.github.com/users/catmando/followers","following_url":"https://api.github.com/users/catmando/following{/other_user}","gists_url":"https://api.github.com/users/catmando/gists{/gist_id}","starred_url":"https://api.github.com/users/catmando/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/catmando/subscriptions","organizations_url":"https://api.github.com/users/catmando/orgs","repos_url":"https://api.github.com/users/catmando/repos","events_url":"https://api.github.com/users/catmando/events{/privacy}","received_events_url":"https://api.github.com/users/catmando/received_events","type":"User","site_admin":false},"created_at":"2016-11-30T23:21:56Z","updated_at":"2016-11-30T23:21:56Z","body":"Here is a patch that I've been testing... suggest we just use as is for now:\r\n```ruby\r\nmodule React\r\n  class RenderingContext\r\n    class << self\r\n      alias pre_patch_render render\r\n      def render(name, *args, &block)\r\n        was_outer_most = !@not_outer_most\r\n        @not_outer_most = true\r\n        pre_patch_render(name, *args, &block)\r\n      ensure\r\n        @not_outer_most = @buffer = nil if was_outer_most\r\n      end\r\n    end\r\n  end\r\nend\r\n```"}}
{"actor":{"display_login":"catmando"}}