0
votes

I have objects that extends NSOperation. I also have NSOperationQueue.

I have a timer that NSLogs operationCount property of that NSOperationQueue every 0.5 seconds.

I add new operations to queue and after all of them are finished, queue logs 0 just as expected.

Problem is that Instruments reports that there are still living NSOperation objects living.

I hold no references to NSOperation, I only alloc-init them and add them to the queue.

The number of living NSOperation objects is 11 (???) in Instruments. If I add 5 new operations, NSLog logs 5... 4.... 3.... 2 .... 1... 0. And instruments are behaving like: 16, 15, 14, 13, 12, 11 ...

Any clue on this?

I could KVO isFinished property and set to nil, but I am I wonder why are those objects still alive.

1
Retain cycle maybe? Are you using ARC?F.X.
ARC it is. And there is no retain cycle as far as I can tell.vale4674
Maybe Cocoa itself is using NSOperations. Have you tried looking at who exactly is retaining them?F.X.
Can I see this through Instruments?vale4674
Yup, I believe so. Use the "Allocations" instrument, check "Record Reference Counts" and run. You should see a list of all the classes in your app. Click on the class you want (NSOperation here), that should show a list of all the instances of that class. Then click on the instance you want, and bam, here is the list of each retain/release call. You should be able to determine which one is too much ;)F.X.

1 Answers

0
votes

It looks like Instruments were causing this since this is not happening anymore and I didn't touch that code before this new tests.