{"action":"created","issue":{"url":"https://api.github.com/repos/elastic/elasticsearch/issues/15789","labels_url":"https://api.github.com/repos/elastic/elasticsearch/issues/15789/labels{/name}","comments_url":"https://api.github.com/repos/elastic/elasticsearch/issues/15789/comments","events_url":"https://api.github.com/repos/elastic/elasticsearch/issues/15789/events","html_url":"https://github.com/elastic/elasticsearch/issues/15789","id":125173350,"number":15789,"title":"Memory leak on get field mapping API","user":{"login":"Mogztter","id":333276,"avatar_url":"https://avatars.githubusercontent.com/u/333276?v=3","gravatar_id":"","url":"https://api.github.com/users/Mogztter","html_url":"https://github.com/Mogztter","followers_url":"https://api.github.com/users/Mogztter/followers","following_url":"https://api.github.com/users/Mogztter/following{/other_user}","gists_url":"https://api.github.com/users/Mogztter/gists{/gist_id}","starred_url":"https://api.github.com/users/Mogztter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Mogztter/subscriptions","organizations_url":"https://api.github.com/users/Mogztter/orgs","repos_url":"https://api.github.com/users/Mogztter/repos","events_url":"https://api.github.com/users/Mogztter/events{/privacy}","received_events_url":"https://api.github.com/users/Mogztter/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-01-06T13:07:11Z","updated_at":"2016-01-06T14:08:10Z","closed_at":null,"body":"Environment:\r\n\r\n * 62 indices\r\n * 50+ types\r\n * Java 7.0_67\r\n * JVM arguments `-Xms8G -Xmx8G`\r\n * Elasticsearch version 1.7.5 (branch 1.7)\r\n\r\nSteps:\r\n\r\n 1. Start Elasticsearch\r\n 2. Execute the following query `http://localhost:9200/logstash/_mapping/field/*` (produced by Kibana)\r\n 3. Wait the response\r\n 4. Run the same query again\r\n\r\nHere is the result (screenshot from JVisualVM);\r\n![mapping-memory-leak-confirmed](https://cloud.githubusercontent.com/assets/333276/12142867/b68a64c0-b47b-11e5-9f04-5fefbe9b6754.JPG)\r\n\r\nAs you can see the first execution of the query took about 1G of memory and the second execution of the query took about 2.5G (more than 2 times more memory than the first execution).\r\nI tried to force GC but no memory is free up.\r\n\r\nUsing MAT, I can see that the memory is filled with `FieldMappingMetaData`.\r\nI'm not sure if this is intended but I `GetFieldMappingsResponse` keeps a reference of the mapping: https://github.com/elastic/elasticsearch/blob/1.7/src/main/java/org/elasticsearch/action/admin/indices/mapping/get/GetFieldMappingsResponse.java#L39\r\n\r\nI didn't try on Elasticsearch 2.x but the code is more or less the same.\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/elastic/elasticsearch/issues/comments/169331410","html_url":"https://github.com/elastic/elasticsearch/issues/15789#issuecomment-169331410","issue_url":"https://api.github.com/repos/elastic/elasticsearch/issues/15789","id":169331410,"user":{"login":"jpountz","id":299848,"avatar_url":"https://avatars.githubusercontent.com/u/299848?v=3","gravatar_id":"","url":"https://api.github.com/users/jpountz","html_url":"https://github.com/jpountz","followers_url":"https://api.github.com/users/jpountz/followers","following_url":"https://api.github.com/users/jpountz/following{/other_user}","gists_url":"https://api.github.com/users/jpountz/gists{/gist_id}","starred_url":"https://api.github.com/users/jpountz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jpountz/subscriptions","organizations_url":"https://api.github.com/users/jpountz/orgs","repos_url":"https://api.github.com/users/jpountz/repos","events_url":"https://api.github.com/users/jpountz/events{/privacy}","received_events_url":"https://api.github.com/users/jpountz/received_events","type":"User","site_admin":false},"created_at":"2016-01-06T14:08:10Z","updated_at":"2016-01-06T14:08:10Z","body":"> I tried to force GC but no memory is free up.\r\n\r\nThis could be because elasticsearch disables explicit GCs. What happens if you keep calling this API, does Elasticsearch run out of memory?"}}