{"action":"created","issue":{"url":"https://api.github.com/repos/yiisoft/yii2/issues/14102","repository_url":"https://api.github.com/repos/yiisoft/yii2","labels_url":"https://api.github.com/repos/yiisoft/yii2/issues/14102/labels{/name}","comments_url":"https://api.github.com/repos/yiisoft/yii2/issues/14102/comments","events_url":"https://api.github.com/repos/yiisoft/yii2/issues/14102/events","html_url":"https://github.com/yiisoft/yii2/issues/14102","id":225902345,"number":14102,"title":"Rendering huge view's causes memory leaks","user":{"login":"awesomeguy3","id":6787924,"avatar_url":"https://avatars3.githubusercontent.com/u/6787924?v=3","gravatar_id":"","url":"https://api.github.com/users/awesomeguy3","html_url":"https://github.com/awesomeguy3","followers_url":"https://api.github.com/users/awesomeguy3/followers","following_url":"https://api.github.com/users/awesomeguy3/following{/other_user}","gists_url":"https://api.github.com/users/awesomeguy3/gists{/gist_id}","starred_url":"https://api.github.com/users/awesomeguy3/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/awesomeguy3/subscriptions","organizations_url":"https://api.github.com/users/awesomeguy3/orgs","repos_url":"https://api.github.com/users/awesomeguy3/repos","events_url":"https://api.github.com/users/awesomeguy3/events{/privacy}","received_events_url":"https://api.github.com/users/awesomeguy3/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-05-03T07:24:15Z","updated_at":"2017-05-03T08:40:29Z","closed_at":null,"body":"I noticed (using Yii2 debugger and memory_get_peak_usage()) that one of my actions take a LOT of memory when rendering, to be specific, around 180MB on the server side. Now, I've been playing around and debugging and trying to see where the memory is leaking, and found out that Controller's render() function triples the memory usage of the view. \r\n\r\n### What steps will reproduce the problem?\r\nHaving huge multidimensional array and generating a lot of HTML from it takes a lot of memory, but not as near as when rendering is finished. I've placed memory_get_peak_usage(); die(); at the end of the view file, and it was third of what it was when render was finished (also checked with memory_get_peak_usage() and got 180MB after rendering. Render partial is around 1/2 of render's memory usage. \r\nPeak memory usage before rendering the view was around 15MB. \r\n\r\n### What is the expected result?\r\nIn this case I wouldn't expect more than 100 MB of memory to be used to finish everything.\r\n\r\n### What do you get instead?\r\nA huge amount of memory consumed.\r\n\r\n### Additional info\r\nPeak memory usage:\r\n- before view ~ 15MB\r\n- at the end of the view file ~ 60MB\r\n- after render ~ 180MB\r\n- browser memory used (mozilla developer toolbar net panel) ~ 5 MB\r\n\r\n| Q                | A\r\n| ---------------- | ---\r\n| Yii version      | 2.0.9\r\n| PHP version      | 7.0.8\r\n| Operating system | Linux CentOs 7\r\n"},"comment":{"url":"https://api.github.com/repos/yiisoft/yii2/issues/comments/298853372","html_url":"https://github.com/yiisoft/yii2/issues/14102#issuecomment-298853372","issue_url":"https://api.github.com/repos/yiisoft/yii2/issues/14102","id":298853372,"user":{"login":"rob006","id":5972388,"avatar_url":"https://avatars1.githubusercontent.com/u/5972388?v=3","gravatar_id":"","url":"https://api.github.com/users/rob006","html_url":"https://github.com/rob006","followers_url":"https://api.github.com/users/rob006/followers","following_url":"https://api.github.com/users/rob006/following{/other_user}","gists_url":"https://api.github.com/users/rob006/gists{/gist_id}","starred_url":"https://api.github.com/users/rob006/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rob006/subscriptions","organizations_url":"https://api.github.com/users/rob006/orgs","repos_url":"https://api.github.com/users/rob006/repos","events_url":"https://api.github.com/users/rob006/events{/privacy}","received_events_url":"https://api.github.com/users/rob006/received_events","type":"User","site_admin":false},"created_at":"2017-05-03T08:40:28Z","updated_at":"2017-05-03T08:40:28Z","body":"Does the use of reference change anything?\r\n\r\n```php\r\n$this->render('view', ['data' => &$data]);\r\n```"}}
{"actor":{"display_login":"rob006"}}