<p dir="auto">Fixing issue <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="57606889" data-permission-text="Title is private" data-url="https://github.com/elastic/elasticsearch/issues/9691" data-hovercard-type="issue" data-hovercard-url="/elastic/elasticsearch/issues/9691/hovercard" href="https://github.com/elastic/elasticsearch/issues/9691">#9691</a> revealed a deeper problem with the QuadPrefixTree's memory usage.  At 1m precision the example shape in <a href="https://gist.github.com/nknize/abbcb87f091b891f85e1">https://gist.github.com/nknize/abbcb87f091b891f85e1</a> consumes more than 1GB of memory.  This is initially alleviated by using 2 bit encoded quads (instead of 1byte) but only delays the problem.  Moreover, as new complex shapes are added duplicate quadcells are created - thus introducing unnecessary redundant memory consumption (an inverted index approach makes mosts sense - its Lucene!).</p>
<p dir="auto">For now, if a QuadTree is used for complex shapes great care must be taken and precision must be sacrificed (something that's automatically done with the distance_error_pct without the user knowing - which is a TERRIBLE approach).  An alternative improvement could be to apply a Hilbert R-Tree - which will be explored as a separate issue.  Or to restrict the accuracy to a lower level of precision (something that's undergoing experimentation).</p>
<p dir="auto"><strong>Elasticsearch version</strong>:<br>
2.3.4</p>
<p dir="auto"><strong>JVM version</strong>:<br>
1.8</p>
<h1 dir="auto">some gc log</h1>
<p dir="auto">[monitor.jvm              ] [Powerpax] [gc][young][132059][21130] duration [756ms], collections [1]/[1.4s], total [756ms]/[10.3m], memory [26.7gb]-&gt;[24.1gb]/[29.6gb<br>
], all_pools {[young] [2.7gb]-&gt;[3.2mb]/[2.7gb]}{[survivor] [20.6mb]-&gt;[240.8mb]/[357.7mb]}{[old] [23.9gb]-&gt;[23.9gb]/[26.5gb]}</p>
<h1 dir="auto">doubt</h1>
<p dir="auto">I use bulk to index. 30 billion doc very day. But some node alway out of cluster because long time full gc after some days.<br>
I dump bin log and find taskManager object cost most of memory(18GB), I doubt why taskManager cost cost many memory ? It cache large number of task(request) ? some body can explain the situation? thanks</p>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://cloud.githubusercontent.com/assets/8613477/17446938/585d0ce0-5b7e-11e6-8833-b2b16622c631.png"><img src="https://cloud.githubusercontent.com/assets/8613477/17446938/585d0ce0-5b7e-11e6-8833-b2b16622c631.png" alt="2016-08-06_023347" style="max-width: 100%;"></a></p>