{"action":"created","issue":{"url":"https://api.github.com/repos/literallycanvas/literallycanvas/issues/492","repository_url":"https://api.github.com/repos/literallycanvas/literallycanvas","labels_url":"https://api.github.com/repos/literallycanvas/literallycanvas/issues/492/labels{/name}","comments_url":"https://api.github.com/repos/literallycanvas/literallycanvas/issues/492/comments","events_url":"https://api.github.com/repos/literallycanvas/literallycanvas/issues/492/events","html_url":"https://github.com/literallycanvas/literallycanvas/issues/492","id":303808550,"number":492,"title":"Possible memory leak caused by loadSnapshot","user":{"login":"martianyi","id":9034452,"avatar_url":"https://avatars1.githubusercontent.com/u/9034452?v=4","gravatar_id":"","url":"https://api.github.com/users/martianyi","html_url":"https://github.com/martianyi","followers_url":"https://api.github.com/users/martianyi/followers","following_url":"https://api.github.com/users/martianyi/following{/other_user}","gists_url":"https://api.github.com/users/martianyi/gists{/gist_id}","starred_url":"https://api.github.com/users/martianyi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/martianyi/subscriptions","organizations_url":"https://api.github.com/users/martianyi/orgs","repos_url":"https://api.github.com/users/martianyi/repos","events_url":"https://api.github.com/users/martianyi/events{/privacy}","received_events_url":"https://api.github.com/users/martianyi/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-03-09T11:20:05Z","updated_at":"2018-03-15T06:45:43Z","closed_at":null,"author_association":"NONE","body":"Because undoStack is not cleaned up, memory usage will increase dramatically on Chrome if you call loadSnapshot for multiple times. \r\nPossible fix is set undoStack to empty in loadSnapshot method.\r\n```\r\nloadSnapshot: (snapshot) ->\r\n     // ...\r\n    if snapshot.shapes\r\n      @shapes = []\r\n      @undoStack = []\r\n    // ...\r\n```"},"comment":{"url":"https://api.github.com/repos/literallycanvas/literallycanvas/issues/comments/373277274","html_url":"https://github.com/literallycanvas/literallycanvas/issues/492#issuecomment-373277274","issue_url":"https://api.github.com/repos/literallycanvas/literallycanvas/issues/492","id":373277274,"user":{"login":"anx-ckreuzberger","id":18396259,"avatar_url":"https://avatars2.githubusercontent.com/u/18396259?v=4","gravatar_id":"","url":"https://api.github.com/users/anx-ckreuzberger","html_url":"https://github.com/anx-ckreuzberger","followers_url":"https://api.github.com/users/anx-ckreuzberger/followers","following_url":"https://api.github.com/users/anx-ckreuzberger/following{/other_user}","gists_url":"https://api.github.com/users/anx-ckreuzberger/gists{/gist_id}","starred_url":"https://api.github.com/users/anx-ckreuzberger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/anx-ckreuzberger/subscriptions","organizations_url":"https://api.github.com/users/anx-ckreuzberger/orgs","repos_url":"https://api.github.com/users/anx-ckreuzberger/repos","events_url":"https://api.github.com/users/anx-ckreuzberger/events{/privacy}","received_events_url":"https://api.github.com/users/anx-ckreuzberger/received_events","type":"User","site_admin":false},"created_at":"2018-03-15T06:45:43Z","updated_at":"2018-03-15T06:45:43Z","author_association":"CONTRIBUTOR","body":"This is not a memory leak (per definition [1]), just some unintended behaviour.\r\n\r\nBut to be fair, resetting ``@undoStack`` (maybe by doing ``@undoStack.length = 0`` in loadSnapshot is a good idea. I guess when you load a (new) snapshot, you want the ``undoStack`` to be empty.\r\n\r\nIf you want, I can make a PR for that.\r\n\r\n[1] Wikipedia says: In computer science, a memory leak is a type of resource leak that occurs when a computer program incorrectly manages memory allocations in such a way that memory which is no longer needed is not released.\r\n\r\n``undoStack`` is still needed and accessed by literally canvas. The unintended behaviour is that ``undoStack`` still contains content from previous snapshots."}}
{"actor":{"display_login":"anx-ckreuzberger"}}