{"action":"created","issue":{"url":"https://api.github.com/repos/Microsoft/ChakraCore/issues/5017","repository_url":"https://api.github.com/repos/Microsoft/ChakraCore","labels_url":"https://api.github.com/repos/Microsoft/ChakraCore/issues/5017/labels{/name}","comments_url":"https://api.github.com/repos/Microsoft/ChakraCore/issues/5017/comments","events_url":"https://api.github.com/repos/Microsoft/ChakraCore/issues/5017/events","html_url":"https://github.com/Microsoft/ChakraCore/issues/5017","id":315989490,"number":5017,"title":"Memory leak in JsSetCurrentContext","user":{"login":"benjamin-bader","id":512212,"avatar_url":"https://avatars1.githubusercontent.com/u/512212?v=4","gravatar_id":"","url":"https://api.github.com/users/benjamin-bader","html_url":"https://github.com/benjamin-bader","followers_url":"https://api.github.com/users/benjamin-bader/followers","following_url":"https://api.github.com/users/benjamin-bader/following{/other_user}","gists_url":"https://api.github.com/users/benjamin-bader/gists{/gist_id}","starred_url":"https://api.github.com/users/benjamin-bader/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/benjamin-bader/subscriptions","organizations_url":"https://api.github.com/users/benjamin-bader/orgs","repos_url":"https://api.github.com/users/benjamin-bader/repos","events_url":"https://api.github.com/users/benjamin-bader/events{/privacy}","received_events_url":"https://api.github.com/users/benjamin-bader/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":7,"created_at":"2018-04-19T18:25:52Z","updated_at":"2018-04-26T22:24:53Z","closed_at":null,"author_association":"MEMBER","body":"Hi folks,\r\n\r\nI've noticed that `JsSetCurrentContext` seems to leak small amounts of memory; see the screenshot below for a backtrace from Instruments on macOS.  We're using ChakraCore in a server process, and during stress testing yesterday I noticed that we were leaking memory.  Instruments shows that `JsSetCurrentContext` calls appear to be the cause; all roads lead to `ThreadContextTLSEntry` in the backtraces.\r\n\r\nIs it possible that there's some required cleanup that I'm missing here?  In our current design, request threads \"borrow\" a runtime from a pool, so we end up calling `JsSetCurrentContext` at least once per request.  Are we supposed to \"un-set\" the context when a thread is finished using a runtime?\r\n\r\n![image](https://user-images.githubusercontent.com/512212/39010464-964e0426-43c3-11e8-980d-2b4eb6a541d3.png)\r\n"},"comment":{"url":"https://api.github.com/repos/Microsoft/ChakraCore/issues/comments/384807544","html_url":"https://github.com/Microsoft/ChakraCore/issues/5017#issuecomment-384807544","issue_url":"https://api.github.com/repos/Microsoft/ChakraCore/issues/5017","id":384807544,"user":{"login":"jackhorton","id":4370013,"avatar_url":"https://avatars2.githubusercontent.com/u/4370013?v=4","gravatar_id":"","url":"https://api.github.com/users/jackhorton","html_url":"https://github.com/jackhorton","followers_url":"https://api.github.com/users/jackhorton/followers","following_url":"https://api.github.com/users/jackhorton/following{/other_user}","gists_url":"https://api.github.com/users/jackhorton/gists{/gist_id}","starred_url":"https://api.github.com/users/jackhorton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jackhorton/subscriptions","organizations_url":"https://api.github.com/users/jackhorton/orgs","repos_url":"https://api.github.com/users/jackhorton/repos","events_url":"https://api.github.com/users/jackhorton/events{/privacy}","received_events_url":"https://api.github.com/users/jackhorton/received_events","type":"User","site_admin":false},"created_at":"2018-04-26T22:24:53Z","updated_at":"2018-04-26T22:24:53Z","author_association":"MEMBER","body":"Looks like this is a \"known\" issue: https://github.com/Microsoft/ChakraCore/blob/5f4fe230acc4c8e99dee252382b2b20ae1f0a0fd/bin/ch/ch.cpp#L813"}}
{"actor":{"display_login":"jackhorton"}}