device: convert runtime.SetFinalizer to AddCleanup (#71)
In PR #66, we tried to address a memory leak by avoiding runtime.SetFinalizer for autodrainingInboundQueue and autodrainingOutboundQueue unless there was something to do. However, when there is work to be done, these finalizers still leak memory because they’re still holding on to a cyclical reference to q. This applies to any platform that relies on a bounded device.WaitPool, like Android and iOS which both declare PreallocatedBuffersPerPool. This patch converts this logic to runtime.AddCleanup which is designed to avoid this problem. Updates tailscale/corp#42776 Signed-off-by: Simon Law <sfllaw@tailscale.com>
This commit is contained in:
parent
2ad9837e6c
commit
cd7ac13b86
2 changed files with 8 additions and 8 deletions
|
|
@ -244,8 +244,8 @@ func (peer *Peer) Start() {
|
|||
|
||||
peer.timersStart()
|
||||
|
||||
device.flushInboundQueue(peer.queue.inbound)
|
||||
device.flushOutboundQueue(peer.queue.outbound)
|
||||
device.flushInboundQueue(peer.queue.inbound.c)
|
||||
device.flushOutboundQueue(peer.queue.outbound.c)
|
||||
|
||||
// Use the device batch size, not the bind batch size, as the device size is
|
||||
// the size of the batch pools.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue