Meik Schuetz wrote:

I am just starting to test my little application for leaks using Instruments. I have got a NSOperation which is doing some JSON communication stuff with my server. The NSOperation is sending an NSDictionary object back to the main thread (using a delegate and performSelectorOnMainThread) when the thread is about to complete.

How was the NSDictionary produced? Is it in the sending thread's autorelease pool?

Does the sending thread own the NSDictionary? Are you transferring ownership to the receiving thread? What does the receiving thread do with the NSDictionary once it's received? Does it relinquish ownership properly?


It happens that the Leaks instrument is finding leaks just right there. To analyse the problem, I created a test app having the same communication method in the main thread. Curiously, the Leaks instrument is not finding any leak in this test application.

Why should that be curious? If it's all running on the main thread, then there won't be any inter-thread ownership issues, nor will there be any inter-thread autorelease pool issues. You can't accurately simulate asynchronous threads using a single-threaded test.


I believe that the NSOperation's main method is encapsulated in some autorelease pool. Is there anything that I need to worry about when passing an NSDictionary between threads?

Ownership. It all comes down to object ownership. If you understand ownership, and transfer of ownership, then things will work properly. If not, then things will go wrong.

You will probably have to post your code. There's no way to know exactly what it's doing just by reading your description.

  -- GG

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to