# Can I print out bitset cache sizes by filter (or what's eating my heap)?

**URL:** <https://discuss.elastic.co/t/can-i-print-out-bitset-cache-sizes-by-filter-or-whats-eating-my-heap/33103>\
**Category:** Elasticsearch\
**Created:** [October 27, 2015, 7:53pm UTC](https://discuss.elastic.co/t/can-i-print-out-bitset-cache-sizes-by-filter-or-whats-eating-my-heap/33103 "2015-10-27T19:53:26Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nikita\_Tovstoles](https://avatars.discourse-cdn.com/v4/letter/n/f17d59/32.png) [@Nikita\_Tovstoles](https://discuss.elastic.co/u/Nikita_Tovstoles)\
**Post date:** [October 27, 2015, 7:53pm UTC](https://discuss.elastic.co/t/can-i-print-out-bitset-cache-sizes-by-filter-or-whats-eating-my-heap/33103/1 "2015-10-27T19:53:26Z")

</div>

After starting to make liberal use of `nested` properties to simulate (denormalized) many-to-many relations, our ES server started routinely throwing OutOfMemory errors several hours after startup under routine, moderate usages (both upserts and queries). Our app issues a fair number of nested filter queries, with inner term filters.

Trying to track down the root cause; wonder if bitsets of nested / term filters are being cached and never evicted, causing eventual OOM. With the above in mind a few questions:

1. can I print out bitset memory alloc by filter? (else - profiling time)
2. are cached filter bitsets ever evicted? on what basis?

thanks,

-nikita

---

<div class="post-metadata">

**Author:** ![msimos](https://avatars.discourse-cdn.com/v4/letter/m/bb73d2/32.png) [@msimos](https://discuss.elastic.co/u/msimos)\
**Post date:** [October 27, 2015, 11:33pm UTC](https://discuss.elastic.co/t/can-i-print-out-bitset-cache-sizes-by-filter-or-whats-eating-my-heap/33103/2 "2015-10-27T23:33:20Z")

</div>

Since using nested documents, how big are your document sizes now? I'd recommend taking a look at:

```auto
GET /_nodes/stats?human

```

Look at segments, field data memory & filter\_cache. The filter cache by default is set to 10% by default and will evict the least recently used data:

[https://www.elastic.co/guide/en/elasticsearch/reference/current/index-modules-cache.html#filter](https://www.elastic.co/guide/en/elasticsearch/reference/current/index-modules-cache.html#filter)

---

<div class="post-metadata">

**Author:** ![mvg](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mvg/32/98890_2.png) [@mvg](https://discuss.elastic.co/u/mvg)\
**Post date:** [October 28, 2015, 3:46am UTC](https://discuss.elastic.co/t/can-i-print-out-bitset-cache-sizes-by-filter-or-whats-eating-my-heap/33103/3 "2015-10-28T03:46:56Z")

</div>

1. No, the bitset filter cache caches bitsets per nested field. (only nested fields that have a parent nested field gets cached) The stats api just expose what the entire cache is taking.
2. If segments are removed by Lucene any cache entry associated with it is removed too. This also applies for the bitset filter cache. But other then that there is no other mechanism that purges the bitset filter cache.

---

<div class="post-metadata">

**Author:** ![Nikita\_Tovstoles](https://avatars.discourse-cdn.com/v4/letter/n/f17d59/32.png) [@Nikita\_Tovstoles](https://discuss.elastic.co/u/Nikita_Tovstoles)\
**Post date:** [October 29, 2015, 7:11pm UTC](https://discuss.elastic.co/t/can-i-print-out-bitset-cache-sizes-by-filter-or-whats-eating-my-heap/33103/4 "2015-10-29T19:11:47Z")

</div>

> But other then that there is no other mechanism that purges the bitset filter cache.

@mvg, thanks for your reply. However, [this doc](https://www.elastic.co/guide/en/elasticsearch/reference/1.7/index-modules-cache.html) says (node) filter cache employs an LRU eviction policy, so does get purged, no? Or am I misunderstanding something?

---

<div class="post-metadata">

**Author:** ![Nikita\_Tovstoles](https://avatars.discourse-cdn.com/v4/letter/n/f17d59/32.png) [@Nikita\_Tovstoles](https://discuss.elastic.co/u/Nikita_Tovstoles)\
**Post date:** [October 30, 2015, 6:08pm UTC](https://discuss.elastic.co/t/can-i-print-out-bitset-cache-sizes-by-filter-or-whats-eating-my-heap/33103/5 "2015-10-30T18:08:25Z")

</div>

just to close this out:

- i came to the conclusion that ES\_HEAP\_SIZE was just too small given our index size, so we increase it and are not seeing OOMs any longer. (1.2G -\> 3G)
- index doc count: 13M
- index store size at rest: 1.5GB; periodically goes up to 2.9G, presumably due to retained deleted docs
- filter cache size: ~ 26M

Thanks to all for help. Nice work on ES and kudos for UX of Kibana/marvel

-nikita

---

<div class="post-metadata">

**Author:** ![Raphael](https://avatars.discourse-cdn.com/v4/letter/r/edb3f5/32.png) [@Raphael](https://discuss.elastic.co/u/Raphael)\
**Post date:** [August 3, 2016, 7:38pm UTC](https://discuss.elastic.co/t/can-i-print-out-bitset-cache-sizes-by-filter-or-whats-eating-my-heap/33103/6 "2016-08-03T19:38:58Z")

</div>

Hi, Martin, I have interest about knowing what you've writed. That only nested fields that have a parent nested field gets cached. There's another source where I can find this information. I'm studying ElasticSerach on my master's degree and I think I will need another source for this information, different from this forum. Can you help me? I have looked at the ES definitive guide and I didnt find it there.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 5, 2017, 10:30pm UTC](https://discuss.elastic.co/t/can-i-print-out-bitset-cache-sizes-by-filter-or-whats-eating-my-heap/33103/7 "2017-07-05T22:30:19Z")

</div>


