Fix a leak related to use of function used in a closure #457
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There is a leak in fileprivate lazy var loader: DataLoader<CacheKey, Record> because the method implicitly uses self. Making the capture explicit and breaking the retain cycle here. This was also covered in WWDC 2024 analyze heap memory talk https://developer.apple.com/wwdc24/10173?time=1748
Leak detected via instruments
![Screenshot 2024-08-07 at 11 41 24 PM](https://private-user-images.githubusercontent.com/3059888/356075414-e3719417-b8ae-4fe2-ac2e-e399cc89605b.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkyMjA0NTEsIm5iZiI6MTczOTIyMDE1MSwicGF0aCI6Ii8zMDU5ODg4LzM1NjA3NTQxNC1lMzcxOTQxNy1iOGFlLTRmZTItYWMyZS1lMzk5Y2M4OTYwNWIucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIxMCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMTBUMjA0MjMxWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9M2JiMDM5YTE5NzUwZWI5MzZlOWM1ZDBkZDY5OWMzMmM5ODc3ZGYyN2FjNzdmYmFhODdlMWIyYjcyMWU2ZTk5ZSZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.Kj7RvHaSnR5qetkXEkpjTCOygwHdzbWF5lcUg8_OaJk)