{"action":"created","issue":{"url":"https://api.github.com/repos/Nukkit/Nukkit/issues/894","repository_url":"https://api.github.com/repos/Nukkit/Nukkit","labels_url":"https://api.github.com/repos/Nukkit/Nukkit/issues/894/labels{/name}","comments_url":"https://api.github.com/repos/Nukkit/Nukkit/issues/894/comments","events_url":"https://api.github.com/repos/Nukkit/Nukkit/issues/894/events","html_url":"https://github.com/Nukkit/Nukkit/pull/894","id":162335579,"number":894,"title":"fix memory leak","user":{"login":"mhsjlw","id":8526903,"avatar_url":"https://avatars.githubusercontent.com/u/8526903?v=3","gravatar_id":"","url":"https://api.github.com/users/mhsjlw","html_url":"https://github.com/mhsjlw","followers_url":"https://api.github.com/users/mhsjlw/followers","following_url":"https://api.github.com/users/mhsjlw/following{/other_user}","gists_url":"https://api.github.com/users/mhsjlw/gists{/gist_id}","starred_url":"https://api.github.com/users/mhsjlw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mhsjlw/subscriptions","organizations_url":"https://api.github.com/users/mhsjlw/orgs","repos_url":"https://api.github.com/users/mhsjlw/repos","events_url":"https://api.github.com/users/mhsjlw/events{/privacy}","received_events_url":"https://api.github.com/users/mhsjlw/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":13,"created_at":"2016-06-26T16:36:44Z","updated_at":"2016-06-27T09:19:49Z","closed_at":"2016-06-26T22:40:21Z","pull_request":{"url":"https://api.github.com/repos/Nukkit/Nukkit/pulls/894","html_url":"https://github.com/Nukkit/Nukkit/pull/894","diff_url":"https://github.com/Nukkit/Nukkit/pull/894.diff","patch_url":"https://github.com/Nukkit/Nukkit/pull/894.patch"},"body":"courtesy of @dktapps\r\n\r\nexplanation:\r\n\r\n**Before patch**:\r\nChunk is unloaded and saved. All entities on the chunk are saved. Level::removeEntity is called on all entities in that chunk to remove them.\r\nLevel::removeEntity kills non-player entities. Result is items and XP being spawned in an unloaded chunk.\r\nMovement updates to these entitities (falling checks etc.) trigger requests to the blocks around the entities. Because the entities are in unloaded chunks, these requests cause the chunks to be reloaded. When the chunk is reloaded, the saved entities are spawned again.\r\nProcess repeats, leaking more and more entities until memory limit is exhausted.\r\n\r\n**After patch**:\r\nChunk is unloaded and saved. All entities on the chunk are saved. Level::removeEntity is called on all entities in that chunk to remove them.\r\nBecause Level::removeEntity now uses close() instead of kill(), no items or exp are dropped, which prevents the leak from beginning."},"comment":{"url":"https://api.github.com/repos/Nukkit/Nukkit/issues/comments/228694495","html_url":"https://github.com/Nukkit/Nukkit/pull/894#issuecomment-228694495","issue_url":"https://api.github.com/repos/Nukkit/Nukkit/issues/894","id":228694495,"user":{"login":"dktapps","id":14214667,"avatar_url":"https://avatars.githubusercontent.com/u/14214667?v=3","gravatar_id":"","url":"https://api.github.com/users/dktapps","html_url":"https://github.com/dktapps","followers_url":"https://api.github.com/users/dktapps/followers","following_url":"https://api.github.com/users/dktapps/following{/other_user}","gists_url":"https://api.github.com/users/dktapps/gists{/gist_id}","starred_url":"https://api.github.com/users/dktapps/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dktapps/subscriptions","organizations_url":"https://api.github.com/users/dktapps/orgs","repos_url":"https://api.github.com/users/dktapps/repos","events_url":"https://api.github.com/users/dktapps/events{/privacy}","received_events_url":"https://api.github.com/users/dktapps/received_events","type":"User","site_admin":false},"created_at":"2016-06-27T09:19:49Z","updated_at":"2016-06-27T09:19:49Z","body":"I was half-asleep when I wrote those comments above and didn't check the actual code first."}}
{"actor":{"display_login":"dktapps"}}