# LEAK: ByteBuf.release() was not called before it's garbage-collected

**URL:** <https://discuss.elastic.co/t/leak-bytebuf-release-was-not-called-before-its-garbage-collected/207063>\
**Category:** Elasticsearch\
**Created:** [November 8, 2019, 7:31am UTC](https://discuss.elastic.co/t/leak-bytebuf-release-was-not-called-before-its-garbage-collected/207063 "2019-11-08T07:31:55Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mac\_Oscar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mac_oscar/32/57357_2.png) [@Mac\_Oscar](https://discuss.elastic.co/u/Mac_Oscar)\
**Post date:** [November 8, 2019, 7:31am UTC](https://discuss.elastic.co/t/leak-bytebuf-release-was-not-called-before-its-garbage-collected/207063/1 "2019-11-08T07:31:55Z")

</div>

Hi,  
I have a problem I have never encountered, so I need some help.  
My es cluster has two masters and four data nodes.  
Master 1 is the standby node and it is also the problem node.

Everything is working normally！！！  
But when I check the log of the master 1, I find this:  
LEAK: ByteBuf.release() was not called before it's garbage-collected. Enable advanced leak reporting to find out where the leak occurred. To enable advanced leak reporting, specify the JVM option '-Dio.netty.leakDetection.level=advanced' or call ResourceLeakDetector.setLevel() See [http://netty.io/wiki/reference-counted-objects.html](http://netty.io/wiki/reference-counted-objects.html) for more information.  
I added "Dio.netty.leakDetection.level=advanced" to the jvm.options as instructed and waited for the question to reappear.

Then i found this:  
LEAK: ByteBuf.release() was not called before it's garbage-collected. See [http://netty.io/wiki/reference-counted-objects.html](http://netty.io/wiki/reference-counted-objects.html) for more information.  
Recent access records: 3  
#3:  
Hint: 'cors' will handle the message from this point.  
#2:  
io.netty.buffer.AdvancedLeakAwareCompositeByteBuf.retain(AdvancedLeakAwareCompositeByteBuf.java:1010)  
#1:  
Hint: 'encoder\_compress' will handle the message from this point.

 ![1](https://us1.discourse-cdn.com/elastic/original/3X/c/e/ce1692dff5569d931c6b422d0a08c00d30d1843e.png) ![2](https://us1.discourse-cdn.com/elastic/original/3X/2/2/224872c0c041b9f8a58447fc9dc63a5d5fa24959.png) ![3](https://us1.discourse-cdn.com/elastic/original/3X/d/e/de3a52c5978db8bd8ddf44de54c963f1833ba0c9.png)  
I've read the introduction of this address: " [http://netty.io/wiki/reference-counted-objects.html](http://netty.io/wiki/reference-counted-objects.html) "  
but I'm still confused. I didn't call netty's code directly. What should I do?  
Help me please!!!!!  
Thanks a lot!

---

<div class="post-metadata">

**Author:** ![Armin\_Braun](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/armin_braun/32/20092_2.png) [@Armin\_Braun](https://discuss.elastic.co/u/Armin_Braun)\
**Post date:** [November 8, 2019, 7:33pm UTC](https://discuss.elastic.co/t/leak-bytebuf-release-was-not-called-before-its-garbage-collected/207063/2 "2019-11-08T19:33:31Z")

</div>

Hi @Mac_Oscar

This looks like a memory leak (and bug that is known in older versions of ES). What version of Elasticsearch are you using?

---

<div class="post-metadata">

**Author:** ![Mac\_Oscar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mac_oscar/32/57357_2.png) [@Mac\_Oscar](https://discuss.elastic.co/u/Mac_Oscar)\
**Post date:** [November 18, 2019, 2:15am UTC](https://discuss.elastic.co/t/leak-bytebuf-release-was-not-called-before-its-garbage-collected/207063/4 "2019-11-18T02:15:35Z")

</div>

Hi @Armin_Braun  
Sorry for the delay.  
My version is 5.6.0,and other nodes do not have this problem

---

<div class="post-metadata">

**Author:** ![Armin\_Braun](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/armin_braun/32/20092_2.png) [@Armin\_Braun](https://discuss.elastic.co/u/Armin_Braun)\
**Post date:** [November 18, 2019, 9:44am UTC](https://discuss.elastic.co/t/leak-bytebuf-release-was-not-called-before-its-garbage-collected/207063/5 "2019-11-18T09:44:32Z")

</div>

@Mac_Oscar

Thanks for getting back to me on this one. `5.6.0` is quite old at this point and there have been various fixes to Netty memory leaks in Elasticsearch as well as Netty itself since it was released.  
There isn't anything you can do to fix this but upgrading to a more recent version of Elasticsearch I'm afraid.

---

<div class="post-metadata">

**Author:** ![Mac\_Oscar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mac_oscar/32/57357_2.png) [@Mac\_Oscar](https://discuss.elastic.co/u/Mac_Oscar)\
**Post date:** [November 25, 2019, 7:37am UTC](https://discuss.elastic.co/t/leak-bytebuf-release-was-not-called-before-its-garbage-collected/207063/6 "2019-11-25T07:37:20Z")

</div>

Hi @Armin_Braun  
Thanks for your advice.  
Without affecting the use, I am ready to continue to use 5.6.0.  
After observation, it is not affected temporarily  
Thanks a lot!

---

<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:** [December 23, 2019, 7:42am UTC](https://discuss.elastic.co/t/leak-bytebuf-release-was-not-called-before-its-garbage-collected/207063/7 "2019-12-23T07:42:20Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
