{"action":"created","issue":{"url":"https://api.github.com/repos/elastic/elasticsearch/issues/16128","repository_url":"https://api.github.com/repos/elastic/elasticsearch","labels_url":"https://api.github.com/repos/elastic/elasticsearch/issues/16128/labels{/name}","comments_url":"https://api.github.com/repos/elastic/elasticsearch/issues/16128/comments","events_url":"https://api.github.com/repos/elastic/elasticsearch/issues/16128/events","html_url":"https://github.com/elastic/elasticsearch/issues/16128","id":127706094,"number":16128,"title":"Memory Leak using InternalSearchHit.sourceAsMap","user":{"login":"timothysoehnlin","id":1264175,"avatar_url":"https://avatars.githubusercontent.com/u/1264175?v=3","gravatar_id":"","url":"https://api.github.com/users/timothysoehnlin","html_url":"https://github.com/timothysoehnlin","followers_url":"https://api.github.com/users/timothysoehnlin/followers","following_url":"https://api.github.com/users/timothysoehnlin/following{/other_user}","gists_url":"https://api.github.com/users/timothysoehnlin/gists{/gist_id}","starred_url":"https://api.github.com/users/timothysoehnlin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/timothysoehnlin/subscriptions","organizations_url":"https://api.github.com/users/timothysoehnlin/orgs","repos_url":"https://api.github.com/users/timothysoehnlin/repos","events_url":"https://api.github.com/users/timothysoehnlin/events{/privacy}","received_events_url":"https://api.github.com/users/timothysoehnlin/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/elastic/elasticsearch/labels/:Java%20API","name":":Java API","color":"009800"},{"url":"https://api.github.com/repos/elastic/elasticsearch/labels/feedback_needed","name":"feedback_needed","color":"d4c5f9"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2016-01-20T15:24:32Z","updated_at":"2016-02-05T18:07:46Z","closed_at":"2016-02-05T18:07:16Z","body":"I'm experiencing an odd behavior in a project I'm currently working on. What I'm seeing is that when I reference an InternalSearchHit.sourceAsMap directly I'm experiencing a memory leak. The code is doing some graph traversal and so there are references to other InternalSearchHit.sourceAsMap documents as well.\r\n\r\nI'm currently writing groovy code, and so part of what I'm seeing is:\r\n\r\n    def docMap = hit.sourceAsMap() \r\n    //Add data into hash map\r\n    //Add other InternalSearchHit.sourceAsMap as child of map\r\n   I end up with a memory leak.\r\n\r\nIf I copy the map using the HashMap constructor:\r\n\r\n    def docMap = new HashMap(hit.sourceAsMap())\r\n    //Add data into hash map\r\n    //Add other InternalSearchHit.sourceAsMap as child of map\r\n\r\nThen the memory leak goes away.\r\n\r\nI took a look at the source for InternalSearchHit and I didn't see anything glaring. At best what I can guess, is that referencing the sourceAsMap object retains a hold on the SearchHit which in turn retains a hold on something else.\r\n"},"comment":{"url":"https://api.github.com/repos/elastic/elasticsearch/issues/comments/180474476","html_url":"https://github.com/elastic/elasticsearch/issues/16128#issuecomment-180474476","issue_url":"https://api.github.com/repos/elastic/elasticsearch/issues/16128","id":180474476,"user":{"login":"jasontedor","id":4744941,"avatar_url":"https://avatars.githubusercontent.com/u/4744941?v=3","gravatar_id":"","url":"https://api.github.com/users/jasontedor","html_url":"https://github.com/jasontedor","followers_url":"https://api.github.com/users/jasontedor/followers","following_url":"https://api.github.com/users/jasontedor/following{/other_user}","gists_url":"https://api.github.com/users/jasontedor/gists{/gist_id}","starred_url":"https://api.github.com/users/jasontedor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jasontedor/subscriptions","organizations_url":"https://api.github.com/users/jasontedor/orgs","repos_url":"https://api.github.com/users/jasontedor/repos","events_url":"https://api.github.com/users/jasontedor/events{/privacy}","received_events_url":"https://api.github.com/users/jasontedor/received_events","type":"User","site_admin":false},"created_at":"2016-02-05T18:07:46Z","updated_at":"2016-02-05T18:07:46Z","body":"I'm closing this since we haven't heard from you; if you do have a script that reproduces the situation, please feel free to attach and reopen."}}