Giter Club home page Giter Club logo

Comments (15)

violetagg avatar violetagg commented on June 1, 2024

@KrishnakanthYachareni From the configuration I don't see any changes related to the memory management, which means that you are running with Pooled ByteBufs. Is it possible that you see this reserved memory?
Check this https://www.programmersought.com/article/9322400832/ ,
https://netty.io/wiki/reference-counted-objects.html and may be this https://projectreactor.io/docs/netty/release/reference/index.html#faq.memory-leaks

from reactor-netty.

KrishnakanthYachareni avatar KrishnakanthYachareni commented on June 1, 2024

@violetagg Yes, my application has been using default Pooled ByteBus, as I did not have any manual configuration related to mememory management. You can see below it is a reserved memory.
image
If you see the memory usage of the pod which is gradually increasing in the pod and memory is not collecting by GC.
image

Why does ByteBuf memory is not clearing, is the following snippet not releasing the buffer properly?

Flux<FcmResponseWrapper> response = fcmRestClient.sendPush(fluxRequests, appName, eventIdentifiers);

List<Tuple2<Long, FcmResponseWrapper>> listOfSendResponses = response.elapsed()
                  .collectList()
                  .block(); // Thread blocking.

from reactor-netty.

violetagg avatar violetagg commented on June 1, 2024

Is it possible to enable memory metrics provided by Reactor Netty
https://projectreactor.io/docs/netty/release/reference/index.html#_metrics_6
reactor.netty.bytebuf.allocator.active.heap.memory
reactor.netty.bytebuf.allocator.active.direct.memory

from reactor-netty.

KrishnakanthYachareni avatar KrishnakanthYachareni commented on June 1, 2024

@violetagg Just to clarify that in my code no other objects are allocating more memory and memeory is leaking from reactor related objects. That I verfied during JVM profiling.

bytebuf are not emitted but ConnectionProvider metrics are emitting. Following code used to enable the reactor metrics. am I missing anything?

Schedulers.enableMetrics(); // in Spring boot main method.

private ConnectionProvider getConnectionProvider() {
        return ConnectionProvider.builder("fcmConnection")
                .metrics(true)
                .build();
    }

    @Bean
    public NettyServerCustomizer nettyServerCustomizer(){
        return httpServer -> httpServer.metrics(true, Function.identity());
    }

My suspect is .subscribeOn(Schedulers.fromExecutor(executor) method with reactor scheduler may causing the leak, Can you please validate the code?

messages.flatMap(msgPair -> webClient.post()
                            .uri(appURI)
                            .header(HttpHeaders.AUTHORIZATION, accessToken)
                            .body(Mono.just(msgPair.getFirst()), FirebaseRequest.class)
                            .exchangeToFlux(clientResponse -> this.handleResponse(clientResponse, msgPair.getSecond())))
                    .subscribeOn(Schedulers.fromExecutor(executor));

from reactor-netty.

violetagg avatar violetagg commented on June 1, 2024

Add this to the client httpClient.metrics(true, Function.identity());

from reactor-netty.

KrishnakanthYachareni avatar KrishnakanthYachareni commented on June 1, 2024

@violetagg I collected the byteBuff memory metric and both seems always constant and same value.
image

from reactor-netty.

violetagg avatar violetagg commented on June 1, 2024

@KrishnakanthYachareni You need the active not the overal memory that is reserved

reactor.netty.bytebuf.allocator.active.heap.memory
reactor.netty.bytebuf.allocator.active.direct.memory

vs

reactor.netty.bytebuf.allocator.used.heap.memory
reactor.netty.bytebuf.allocator.used.direct.memory

from reactor-netty.

KrishnakanthYachareni avatar KrishnakanthYachareni commented on June 1, 2024

@violetagg My bad, I miss understood the mertics name. Both memories are most of the time showing as 0 but some time direct memory have certain value and active heap memory is always 0. what does it mean?

Note: Just to mention Non-Heap memory is gradually increasing and not going down.

image

image

from reactor-netty.

KrishnakanthYachareni avatar KrishnakanthYachareni commented on June 1, 2024

Took this screenshot after few hours of running and later again both memories went down to 0
image

from reactor-netty.

violetagg avatar violetagg commented on June 1, 2024

@KrishnakanthYachareni So to summarise the active memory is not increasing constantly but it returns to 0?

from reactor-netty.

KrishnakanthYachareni avatar KrishnakanthYachareni commented on June 1, 2024

@violetagg Yes. that is right!

from reactor-netty.

violetagg avatar violetagg commented on June 1, 2024

@KrishnakanthYachareni So looks like no memory leaks?

from reactor-netty.

KrishnakanthYachareni avatar KrishnakanthYachareni commented on June 1, 2024

@violetagg I did these changes, this could be a reason memory leak got fixed.

From

webClient.subscribeOn(Schedulers.fromExecutor(executor));

To

webClient.publishOn(Schedulers.fromExecutor(executor));

from reactor-netty.

violetagg avatar violetagg commented on June 1, 2024

@KrishnakanthYachareni I cannot comment on the change from subscribeOn/publishOn without having a reproducible example. That said should I close this, if the above is working for you?

from reactor-netty.

KrishnakanthYachareni avatar KrishnakanthYachareni commented on June 1, 2024

@violetagg yes please, you can close it.

from reactor-netty.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.