{"action":"created","issue":{"url":"https://api.github.com/repos/MovingBlocks/Terasology/issues/2461","repository_url":"https://api.github.com/repos/MovingBlocks/Terasology","labels_url":"https://api.github.com/repos/MovingBlocks/Terasology/issues/2461/labels{/name}","comments_url":"https://api.github.com/repos/MovingBlocks/Terasology/issues/2461/comments","events_url":"https://api.github.com/repos/MovingBlocks/Terasology/issues/2461/events","html_url":"https://github.com/MovingBlocks/Terasology/issues/2461","id":173636461,"number":2461,"title":"Memory leak in the rendering pipline","user":{"login":"flo","id":3511,"avatar_url":"https://avatars.githubusercontent.com/u/3511?v=3","gravatar_id":"","url":"https://api.github.com/users/flo","html_url":"https://github.com/flo","followers_url":"https://api.github.com/users/flo/followers","following_url":"https://api.github.com/users/flo/following{/other_user}","gists_url":"https://api.github.com/users/flo/gists{/gist_id}","starred_url":"https://api.github.com/users/flo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/flo/subscriptions","organizations_url":"https://api.github.com/users/flo/orgs","repos_url":"https://api.github.com/users/flo/repos","events_url":"https://api.github.com/users/flo/events{/privacy}","received_events_url":"https://api.github.com/users/flo/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/MovingBlocks/Terasology/labels/3D-Wizardry","name":"3D-Wizardry","color":"fbca04"},{"url":"https://api.github.com/repos/MovingBlocks/Terasology/labels/Architecture","name":"Architecture","color":"A13027"},{"url":"https://api.github.com/repos/MovingBlocks/Terasology/labels/Bug","name":"Bug","color":"e10c02"},{"url":"https://api.github.com/repos/MovingBlocks/Terasology/labels/Optimisation","name":"Optimisation","color":"7B8075"}],"state":"open","locked":false,"assignee":{"login":"tdgunes","id":136392,"avatar_url":"https://avatars.githubusercontent.com/u/136392?v=3","gravatar_id":"","url":"https://api.github.com/users/tdgunes","html_url":"https://github.com/tdgunes","followers_url":"https://api.github.com/users/tdgunes/followers","following_url":"https://api.github.com/users/tdgunes/following{/other_user}","gists_url":"https://api.github.com/users/tdgunes/gists{/gist_id}","starred_url":"https://api.github.com/users/tdgunes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tdgunes/subscriptions","organizations_url":"https://api.github.com/users/tdgunes/orgs","repos_url":"https://api.github.com/users/tdgunes/repos","events_url":"https://api.github.com/users/tdgunes/events{/privacy}","received_events_url":"https://api.github.com/users/tdgunes/received_events","type":"User","site_admin":false},"assignees":[{"login":"tdgunes","id":136392,"avatar_url":"https://avatars.githubusercontent.com/u/136392?v=3","gravatar_id":"","url":"https://api.github.com/users/tdgunes","html_url":"https://github.com/tdgunes","followers_url":"https://api.github.com/users/tdgunes/followers","following_url":"https://api.github.com/users/tdgunes/following{/other_user}","gists_url":"https://api.github.com/users/tdgunes/gists{/gist_id}","starred_url":"https://api.github.com/users/tdgunes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tdgunes/subscriptions","organizations_url":"https://api.github.com/users/tdgunes/orgs","repos_url":"https://api.github.com/users/tdgunes/repos","events_url":"https://api.github.com/users/tdgunes/events{/privacy}","received_events_url":"https://api.github.com/users/tdgunes/received_events","type":"User","site_admin":false},{"login":"emanuele3d","id":6934584,"avatar_url":"https://avatars.githubusercontent.com/u/6934584?v=3","gravatar_id":"","url":"https://api.github.com/users/emanuele3d","html_url":"https://github.com/emanuele3d","followers_url":"https://api.github.com/users/emanuele3d/followers","following_url":"https://api.github.com/users/emanuele3d/following{/other_user}","gists_url":"https://api.github.com/users/emanuele3d/gists{/gist_id}","starred_url":"https://api.github.com/users/emanuele3d/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/emanuele3d/subscriptions","organizations_url":"https://api.github.com/users/emanuele3d/orgs","repos_url":"https://api.github.com/users/emanuele3d/repos","events_url":"https://api.github.com/users/emanuele3d/events{/privacy}","received_events_url":"https://api.github.com/users/emanuele3d/received_events","type":"User","site_admin":false}],"milestone":null,"comments":9,"created_at":"2016-08-28T08:46:27Z","updated_at":"2016-08-30T15:11:56Z","closed_at":null,"body":"### What you were trying to do\r\n\r\nNormally playing the game with water reflections set to \"sky only\" (default setting I assume).\r\n\r\n### What actually happened\r\nThe game needs constantly more memory as the field `chunksOpaqueReflection` field in `RenderQueuesHelper` grows constantly in size.\r\n\r\nThe method `renderChunks` of `WorldRendererImpl` is the only method I could find that removed entities from that list. The method `renderChunks`  gets however only called by`WorldReflectionNode` if the `reflectiveWater` config option is set.\r\n\r\n\r\nThe list gets filled multiple times with the same chunks again and again. \r\nThe expected max size specified by the  `MAX_LOADABLE_CHUNKS`  constant of `RenderableWorldImpl` gets thus easily topped. (Btw. I think it would have been better to not have this constant: 1. It is less code. 2. It can not lead another developer to wrongly assume that the queue has a size limit(was that the intention?). 3. The CPU overhead for growing the list is minimal (in the worst case twice as many assignments to array positions need to be made), while on the other size the list is not larger as it needs to be on systems that have less memory.)\r\n\r\nMaybe the queue could be cleared before it gets filled again?\r\n\r\nWhen this issue gets fixed, it should be checked if the other piplines have potentially the same issue.\r\n\r\n### How to reproduce\r\n\r\n1. Start the game from the IDE with\"water reflections\" set to \"sky only\"\r\n2. Set a breakpoint and have a look at the size of the  `chunksOpaqueReflection` field in `RenderQueuesHelper`\r\n\r\n<bountysource-plugin>\r\n---\r\nWant to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/37349433-memory-leak-in-the-rendering-pipline?utm_campaign=plugin&utm_content=tracker%2F5279&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F5279&utm_medium=issues&utm_source=github).\r\n</bountysource-plugin>"},"comment":{"url":"https://api.github.com/repos/MovingBlocks/Terasology/issues/comments/243473207","html_url":"https://github.com/MovingBlocks/Terasology/issues/2461#issuecomment-243473207","issue_url":"https://api.github.com/repos/MovingBlocks/Terasology/issues/2461","id":243473207,"user":{"login":"emanuele3d","id":6934584,"avatar_url":"https://avatars.githubusercontent.com/u/6934584?v=3","gravatar_id":"","url":"https://api.github.com/users/emanuele3d","html_url":"https://github.com/emanuele3d","followers_url":"https://api.github.com/users/emanuele3d/followers","following_url":"https://api.github.com/users/emanuele3d/following{/other_user}","gists_url":"https://api.github.com/users/emanuele3d/gists{/gist_id}","starred_url":"https://api.github.com/users/emanuele3d/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/emanuele3d/subscriptions","organizations_url":"https://api.github.com/users/emanuele3d/orgs","repos_url":"https://api.github.com/users/emanuele3d/repos","events_url":"https://api.github.com/users/emanuele3d/events{/privacy}","received_events_url":"https://api.github.com/users/emanuele3d/received_events","type":"User","site_admin":false},"created_at":"2016-08-30T15:11:56Z","updated_at":"2016-08-30T15:11:56Z","body":"I just took an in-depth look at the relevant code. In my opinion the quickest solution is as simple as having\r\n\r\n```\r\nif (sceneVisibleInReflections && isChunkVisibleReflection(chunk)) {\r\n    renderQueues.chunksOpaqueReflection.add(chunk);\r\n}\r\n```\r\n\r\nLonger term I'd like the whole `RenderableWorldImpl` class to become a number of \"caching nodes\" in the dag, processed before the rendering nodes, although right now I can't quite see how this can be achieved - it's hard to think how `RenderableWorldImpl` can be split into nodes.\r\n\r\nRegarding the question \"why is this queue different in the first place\": it looks like a straightforward bug that was either there when this code was initially written or that was introduced somewhere along the line. Perhaps it was never detected probably because Terasology crashes or is shut down before memory consumption becomes an issue. Also, the `chunkOpaqueShadow `queue is an example of a queue dependent on the rendering config.\r\n\r\nI don't have the time right now to do the fix as I want to go through the steps @flo suggested to make sure the fix does the job. @tdgunes, if you have an itch to deal with this go ahead and do it - just let me know if you do. Otherwise I'll take care of it sometimes this week I hope."}}
{"actor":{"display_login":"emanuele3d"}}