Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Netty instrumentation causes memory leak and more #2705

Closed
raptium opened this issue Apr 3, 2021 · 5 comments · Fixed by #2851
Closed

Netty instrumentation causes memory leak and more #2705

raptium opened this issue Apr 3, 2021 · 5 comments · Fixed by #2851
Labels
bug Something isn't working

Comments

@raptium
Copy link

raptium commented Apr 3, 2021

Describe the bug
io.netty.channel.ChannelFuture#addListener() is transformed to wrap the input listener with a helper class.
However the removeListener() removeListeners() counterparts are never transformed. Once a listener is added to the future, it can never be removed. This may cause memory leak and even logical incorrectness.

Steps to reproduce

import io.netty.channel.embedded.EmbeddedChannel;
import io.netty.util.concurrent.Future;
import io.netty.util.concurrent.GenericFutureListener;

public class NettyChannelFutureDemo {
    public static void main(String[] args) {
        EmbeddedChannel channel = new EmbeddedChannel();
        for (int i = 0; i < 100; i++) {
            GenericFutureListener<Future<Object>> listener = future -> {
                System.out.println("channel closed");
            };
            channel.closeFuture().addListener(listener);
            channel.closeFuture().removeListener(listener); // not removed if netty instrumentation is on
        }
        try {
            channel.close().await();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}

What did you expect to see?
channel closed should never be printed since listeners are removed before the future completes.

What did you see instead?
channel closed is printed 100 times.

What version are you using?
v1.0.1

Environment
Compiler: AdoptOpenJDK 11.0.10
OS: Microsoft Windows 10

Additional context
N/A

@dkulig
Copy link

dkulig commented May 13, 2021

Hi, can I get some sort of an ETA when this will be released?

@iNikem
Copy link
Contributor

iNikem commented May 14, 2021

We plan to release new version of the agent during the next several days.

@dkulig
Copy link

dkulig commented May 17, 2021

@iNikem thanks for the update. I can see that v1.2.0 has been released however this guy seems to not be included in the Bug fixes. Does that mean it will be included in the next release?

@mateuszrzeszutek
Copy link
Member

Oh, the fix is there, but the note does not say anything about memleak explicitly:

@dkulig
Copy link

dkulig commented May 17, 2021

thanks @mateuszrzeszutek

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
4 participants