What happens if you leak an `any Channel`?

if i drop an any Channel instance, will the channel be closed automatically?

No. Explicit lifecycles with knowable resource usage is a core pillar of the whole NIO family. Fully closing a Channel cannot be done in a deinit because it cannot be done synchronously.

If you do want to initiate the shutdown of a Channel from deinit, you would wrap the Channel in your own thing that calls self.channel.close(promise: nil) in its deinit.

1 Like