When I create a signal and bring it into the scope of a function, its effective retain count is 0 per Cocoa conventions:
RACSignal *signal = [self createSignal];
I am trying to solve the memory management mystery of ReactiveCocoa 2.5
RACSubject* subject = [RACSubject subject];
RACSignal* signal = [RACSignal return:@(1)];
NSLog(@"Retain count of RACSubject %ld", CFGetRetainCount((__bridge CFTypeRef)subject));
NSLog(@"Retain count of RACSignal %ld", CFGetRetainCount((__bridge CFTypeRef)signal));
The first line output 1
, and the second line output 2
.
It seems that RACSignal
will be retained somewhere, while RACSubject
is not.
If you don't explicitly retain RACSubject
, it will be deallocated when the program exits the current scope.