{"action":"created","issue":{"url":"https://api.github.com/repos/jayway/JsonPath/issues/94","labels_url":"https://api.github.com/repos/jayway/JsonPath/issues/94/labels{/name}","comments_url":"https://api.github.com/repos/jayway/JsonPath/issues/94/comments","events_url":"https://api.github.com/repos/jayway/JsonPath/issues/94/events","html_url":"https://github.com/jayway/JsonPath/issues/94","id":82711081,"number":94,"title":"memory leak","user":{"login":"tranwarpxl","id":12668874,"avatar_url":"https://avatars.githubusercontent.com/u/12668874?v=3","gravatar_id":"","url":"https://api.github.com/users/tranwarpxl","html_url":"https://github.com/tranwarpxl","followers_url":"https://api.github.com/users/tranwarpxl/followers","following_url":"https://api.github.com/users/tranwarpxl/following{/other_user}","gists_url":"https://api.github.com/users/tranwarpxl/gists{/gist_id}","starred_url":"https://api.github.com/users/tranwarpxl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tranwarpxl/subscriptions","organizations_url":"https://api.github.com/users/tranwarpxl/orgs","repos_url":"https://api.github.com/users/tranwarpxl/repos","events_url":"https://api.github.com/users/tranwarpxl/events{/privacy}","received_events_url":"https://api.github.com/users/tranwarpxl/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":9,"created_at":"2015-05-30T05:36:19Z","updated_at":"2015-10-09T13:53:54Z","closed_at":null,"body":"One of our QA servers ran out of memory, looks like there is a memory leak in Cache.java.\r\nA simple single-threaded program to reproduce the issue is below.\r\nI think it is better to allow the user to disable the cache, and let the user create (and cache) CompiledPath instances.\r\n\r\n    public static void main(String[] arg) {\r\n        Cache cache = new Cache(200);\r\n        Path dummy = new CompiledPath(null, false);\r\n        for (int i = 0; i < 10000; ++i) {\r\n           String key = String.valueOf(i);\r\n           cache.get(key);\r\n           cache.put(key, dummy);\r\n        }\r\n        System.out.println(\"cache size: \" + cache.size());\r\n    }\r\n"},"comment":{"url":"https://api.github.com/repos/jayway/JsonPath/issues/comments/146877580","html_url":"https://github.com/jayway/JsonPath/issues/94#issuecomment-146877580","issue_url":"https://api.github.com/repos/jayway/JsonPath/issues/94","id":146877580,"user":{"login":"orangeven","id":2229928,"avatar_url":"https://avatars.githubusercontent.com/u/2229928?v=3","gravatar_id":"","url":"https://api.github.com/users/orangeven","html_url":"https://github.com/orangeven","followers_url":"https://api.github.com/users/orangeven/followers","following_url":"https://api.github.com/users/orangeven/following{/other_user}","gists_url":"https://api.github.com/users/orangeven/gists{/gist_id}","starred_url":"https://api.github.com/users/orangeven/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/orangeven/subscriptions","organizations_url":"https://api.github.com/users/orangeven/orgs","repos_url":"https://api.github.com/users/orangeven/repos","events_url":"https://api.github.com/users/orangeven/events{/privacy}","received_events_url":"https://api.github.com/users/orangeven/received_events","type":"User","site_admin":false},"created_at":"2015-10-09T13:53:54Z","updated_at":"2015-10-09T13:53:54Z","body":"There is a bug in the implementation of com.jayway.jsonpath.internal.Cache. \r\nThe maximal size of the internal Map and Deque could be exceeded. The bug is easy to reproduce, just run: \r\n```\r\nIntStream.range(0,1000).forEach(i -> {\r\n      PathCompiler.compile(\"test\" + i);\r\n    });\r\n ```\r\nand observe at the end the size of the Map and Deque. The keys are added twist to the Deque. \r\nI am able to observe the Deque with 190K elements on a test server. Lots of tomcat threads are blocked since it takes a lot of time to add/delete element from the Deque and Map. The server comes at the end to OutOfMemoryException. \r\n"}}