ReactiveSwift icon indicating copy to clipboard operation
ReactiveSwift copied to clipboard

Memory leak in Property.swift

Open seanmcneil opened this issue 8 years ago • 6 comments

I've been working to track down leaks within our app and have found that there appears to be a common thread to all of them.

Under fileprivate init(unsafeProducer: SignalProducer<Value, NoError>) I am seeing multiple leaks from different parts of my app that all point to this call:

disposable.inner = unsafeProducer.start { [weak box] event in

This is happening with the current 4.0 version, as well as 3.1.

I am using XCode 9.4.1 and am targeting an iOS 11.4.1 device (so leak is seen on hardware and not in simulator).

In most of the cases I have identified, it is happening when accessing a Property value.

seanmcneil avatar Sep 26 '18 22:09 seanmcneil

Any property that uses that init leaks for me too.

dox-mark avatar Oct 15 '18 15:10 dox-mark

How are you seeing that this is a leak?

Does it still appear as a leak after that SignalProducer completes?

ReactiveSwift does some things that can result in false positives in Instruments.

mdiep avatar Oct 19 '18 18:10 mdiep

class Test {
    var urlProperty: Property<URL>
    var anotherUrlProperty: Property<URL>
    
    init() {
        
        urlProperty = Property<URL>(value: URL(string: "http://google.com")!)
        
        // Leak!
        anotherUrlProperty = Property<URL>(urlProperty)
    }
}

I just created a new project and instantiated this Test class and Instruments shows the second property leaking.

dox-mark avatar Oct 19 '18 18:10 dox-mark

I don't see any leaks with that snippet in Instruments.

mdiep avatar Nov 14 '18 13:11 mdiep

leak On device I see this leak.

dox-mark avatar Nov 14 '18 17:11 dox-mark

Hello. 👋 Thanks for opening this issue. Due to inactivity, we will soft close the issue. If you feel that it should remain open, please let us know. 😄

RuiAAPeres avatar Jul 21 '21 20:07 RuiAAPeres