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

PeerConnection Listener Memory Leak? #135

Open
cal2195 opened this issue Apr 25, 2016 · 1 comment
Open

PeerConnection Listener Memory Leak? #135

cal2195 opened this issue Apr 25, 2016 · 1 comment

Comments

@cal2195
Copy link

cal2195 commented Apr 25, 2016

Hello,

I've been working with this library, and I've come across a problem. While using the PeerDHT, after a few hours, my application crashes with OutOfMemory. It appears that the PeerConnections aren't being GC'd, and they build up after a couple of hours!

After inspecting the heap dump, I can see a NioDatagramChannel with 390,509 closeFuture listeners attached, most of which are PeerConnections?

Am I doing something wrong, or is there a reason why tens of thousands of PeerConnections are persisting between 4 peers?

Thanks!

@cal2195
Copy link
Author

cal2195 commented Apr 25, 2016

After some testing, removing

private void addCloseListener(final ChannelFuture channelFuture) {
        channelFuture.channel().closeFuture().addListener(new GenericFutureListener<Future<? super Void>>() {
            @Override
            public void operationComplete(Future<? super Void> arg0) throws Exception {
                LOG.debug("About to close the connection {}, {}.",  channelFuture.channel(), initiator ? "initiator" : "from-disptacher");
                closeFuture.done();
            }
        });
    }

from PeerConnection.java seems to have stopped the problem. Is there a good way of preventing this memory leak other than this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant