Giter Club home page Giter Club logo

Comments (4)

pavelhlushchanka avatar pavelhlushchanka commented on May 16, 2024

Or i guess it could be even better if event bus has client-specific scope i.e each client has its own event bus and listeners. So once client is done, so all the client-related things will be collected by GC. In this case we don't really need to have a way to remove listeners. We can silence them if it's required until the client is done.

from bt.

atomashpolskiy avatar atomashpolskiy commented on May 16, 2024

I'd prefer to stick with one event bus per runtime, but this is definitely a (minor) memory leak, so it would make sense to remove torrent-specific listeners, once the torrent is done or cancelled (i.e. the corresponding BtClient has terminated). The best place to do this should be somewhere in the processing chain (see bt.processor.TorrentProcessorFactory)

from bt.

ckovorodkin avatar ckovorodkin commented on May 16, 2024

but this is definitely a (minor) memory leak

Each successful handshake adds two listeners. This can be a serious memory leak. Especially when remote peer is malignant and creates incoming connections in loop.

private void subscribeHandler(TorrentId torrentId, ChannelHandler channelHandler) {
eventSource.onTorrentStarted(event -> {
if (event.getTorrentId().equals(torrentId)) {
channelHandler.activate();
}
});
eventSource.onTorrentStopped(event -> {
if (event.getTorrentId().equals(torrentId)) {
channelHandler.deactivate();
}
});
}

from bt.

atomashpolskiy avatar atomashpolskiy commented on May 16, 2024

I guess it's around 30 bytes per connection, does not seem so critical. But again, I agree that this needs to be addressed.

from bt.

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.