apple / swift-async-algorithms

Async Algorithms for Swift
Apache License 2.0
2.95k stars 147 forks source link

Fix memory leak in Lock #331

Open orobio opened 5 days ago

orobio commented 5 days ago

The platform lock is never deallocated, which results in a leak. Since the platform lock is owned by Lock, I thought it would be fine to make deallocation part of deinitialize() and not have a separate deallocate() function. Especially since initialization of the lock is also mixed into allocate() already.

xtremekforever commented 5 days ago

This appears to fix the memleak we saw with cancelOnGracefulShutdown() in the swift-service-lifecycle library. I opened an issue* for this here detailing the behavior of this leak:

https://github.com/swift-server/swift-service-lifecycle/issues/188