Skip to content

Commit f3f8217

Browse files
authored
[6.1] Fix retain cycle in LLBuildProgressTracker (#8308)
- **Explanation**: `self.taskTracker.onTaskProgressUpdateText` captured `self` strongly, creating a reference cycle in `LLBuildProgressTracker`, which caused it to never get deallocated. - **Scope**: Manifested as a memory leak in SourceKit-LSP - **Issue**: n/a - **Original PR**: #8305 - **Risk**: Low, just captures a delegate weakly - **Testing**: Verified that this fixes the memory leak we saw - **Reviewer**: @MaxDesiatov
1 parent e0c6ff2 commit f3f8217

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Sources/Build/LLBuildProgressTracker.swift

+4-2
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,10 @@ final class LLBuildProgressTracker: LLBuildBuildSystemDelegate, SwiftCompilerOut
180180
} ?? [:]
181181
self.swiftParsers = swiftParsers
182182

183-
self.taskTracker.onTaskProgressUpdateText = { progressText, _ in
184-
self.queue.async {
183+
self.taskTracker.onTaskProgressUpdateText = { [weak self] progressText, _ in
184+
guard let self else { return }
185+
self.queue.async { [weak self] in
186+
guard let self else { return }
185187
self.delegate?.buildSystem(self.buildSystem, didUpdateTaskProgress: progressText)
186188
}
187189
}

0 commit comments

Comments
 (0)