Manuscript icon indicating copy to clipboard operation
Manuscript copied to clipboard

Strong reference to `targetItem` in `LayoutItem` can cause memory leak

Open t089 opened this issue 6 years ago • 0 comments

The LayoutItem tuple contains a strong reference to the targetItem view. This can cause a memory retain cycle if the view itself maintains a strong reference to the layout item tuple.

https://github.com/floriankrueger/Manuscript/blob/bb21c1c164bff9cc0fcd5b362752e125e013b324/Sources/LayoutItem.swift#L34

Maybe a possible fix would be to make LayoutItem a final class with a weak reference to targetItem.

Of course the necessity of LayoutItem is questionable in the first place, because the layout constraint already has a unowned (!) reference to the two parties participating in the constraint (firstItem, secondItem).

t089 avatar Aug 01 '18 06:08 t089