{"action":"closed","issue":{"url":"https://api.github.com/repos/magnars/optimus/issues/48","labels_url":"https://api.github.com/repos/magnars/optimus/issues/48/labels{/name}","comments_url":"https://api.github.com/repos/magnars/optimus/issues/48/comments","events_url":"https://api.github.com/repos/magnars/optimus/issues/48/events","html_url":"https://github.com/magnars/optimus/issues/48","id":124616856,"number":48,"title":"V8 usage causes memory leaks","user":{"login":"arohner","id":15422,"avatar_url":"https://avatars.githubusercontent.com/u/15422?v=3","gravatar_id":"","url":"https://api.github.com/users/arohner","html_url":"https://github.com/arohner","followers_url":"https://api.github.com/users/arohner/followers","following_url":"https://api.github.com/users/arohner/following{/other_user}","gists_url":"https://api.github.com/users/arohner/gists{/gist_id}","starred_url":"https://api.github.com/users/arohner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arohner/subscriptions","organizations_url":"https://api.github.com/users/arohner/orgs","repos_url":"https://api.github.com/users/arohner/repos","events_url":"https://api.github.com/users/arohner/events{/privacy}","received_events_url":"https://api.github.com/users/arohner/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-01-02T23:15:12Z","updated_at":"2016-01-03T01:39:12Z","closed_at":"2016-01-03T01:39:12Z","body":"My app is using https://github.com/stuartsierra/component. As is expected w/ component, I create a new system for each test. Recently, tests started failing on CircleCI because my app was using more than 4GB of RAM. As part of my system creation, I create a full optimus middleware, with all optimizations enabled. \r\n\r\nI was clearly leaking memory, and it wasn't part of the java heap. I ran the leak down, and it is caused by optimus leaking v8 context handles in `optimus.optimizations.minify`\r\n\r\nAs proof, run `ps -o rss <pid of your clojure repl>`\r\n\r\nthen run:\r\n\r\n`(dotimes [i 1000] (v8.core/cleanup-context (v8.core/create-context)))`\r\n\r\nobserve essentially no increase in memory usage. Then run:\r\n\r\n`(dotimes [i 1000] (v8.core/create-context))`\r\n\r\nAnd note massive increase in memory usage. (500MB -> 1500MB for me). Note that every usage of v8/create-context in minify.clj fails to call `v8.core/cleanup-context`. If you repeatedly load assets, or minify a large number of files, this will cause enormous memory usage. \r\n\r\n"}}