Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ElasticSearch Java TransportClient leaking byte[]

ElasticSearch Java TransportClient 5.5.1 seems to be leaking byte arrays. Even if i just connect and close, commenting the code in between, it leaks.

The code:

try (PreBuiltTransportClient preBuiltTransportClient = new PreBuiltTransportClient(settings)) {
     try(TransportClient transportClient=preBuiltTransportClient.addTransportAddress(
            new InetSocketTransportAddress(InetAddress.getByName(endPoint),javaPort))){
         //do something
     }
}

Plugin loading log (may indicate something):

Loaded plugins log VisualVM Heap dump showing byte[] allocated size on the heap (after forcing a garbage collection):

VisualVM

Seems to be the same problem as posted here: https://discuss.elastic.co/t/are-there-memory-leaks-in-elasticsearchs-transportclient-5-4-3-or-is-my-code-flawed/91989/5

Not sure if relevant, but I am using Spring boot on the same project.

Any ideas?

EDIT:

Seems to be related to Compression:

enter image description here

EDIT2:

The memory consumption increases greatly on TransportClientNodesService.addTransportAddresses

like image 415
Thiago Sayão Avatar asked Nov 07 '22 18:11

Thiago Sayão


1 Answers

Solution here: https://github.com/elastic/elasticsearch/issues/26048

It's not a leak, it's from netty pooled allocator.

Set io.netty.allocator.type=unpooled to disable.

System.setProperty("io.netty.allocator.type", "unpooled");

OR

-Dio.netty.allocator.type=unpooled 
like image 75
Thiago Sayão Avatar answered Nov 15 '22 08:11

Thiago Sayão