Skip to content

Commit

Permalink
Fix leak in internal implementation of a lock (#337)
Browse files Browse the repository at this point in the history
While debugging a memory issue in one of our applications, we found a
large number of leaked lock instances. This PR fixes the small but
rapidly accumulating leak in the internal `Lock` implementation.

Signed-off-by: Franz Höpfner <[email protected]>
  • Loading branch information
kinnarr authored Jan 14, 2025
1 parent 9740437 commit cee49ee
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Libraries/Connect/Internal/Utilities/Lock.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ final class Lock: @unchecked Sendable {
self.underlyingLock.initialize(to: os_unfair_lock())
}

deinit {
self.underlyingLock.deinitialize(count: 1)
self.underlyingLock.deallocate()
}

/// Perform an action within the context of the lock.
///
/// - parameter action: Closure to be executed in the context of the lock.
Expand Down

0 comments on commit cee49ee

Please sign in to comment.