0

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.

vale4674
  • 4,161
  • 13
  • 47
  • 72
  • Retain cycle maybe? Are you using ARC? – F.X. Oct 09 '12 at 17:35
  • ARC it is. And there is no retain cycle as far as I can tell. – vale4674 Oct 09 '12 at 19:02
  • Maybe Cocoa itself is using NSOperations. Have you tried looking at who exactly is retaining them? – F.X. Oct 09 '12 at 19:07
  • Can I see this through Instruments? – vale4674 Oct 09 '12 at 19:15
  • 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. Oct 09 '12 at 21:03
  • Just took a sample screenshot of what you should get : http://tinypic.com/r/28sycm9/6 – F.X. Oct 09 '12 at 21:10
  • Will try it tomorrow. I was profiling with memory leaks. – vale4674 Oct 09 '12 at 21:18
  • It looks like that was some kind of "anomaly" in Instruments since I can't reproduce this anymore. NSOperation objects are realeasing normally. – vale4674 Oct 10 '12 at 07:19

1 Answers1

0

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

vale4674
  • 4,161
  • 13
  • 47
  • 72