• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
NSRunLoop and NSURL
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSRunLoop and NSURL


  • Subject: NSRunLoop and NSURL
  • From: Drew McCormack <email@hidden>
  • Date: Thu, 12 Dec 2002 15:25:50 +0100

I am using ThreadWorker to spin off a thread to download some data and do some other stuff, but I have discovered that the thread never finishes, and I thus have a bad memory leak. I am using NSURL with the NSString method "stringWithContentsOfURL:" to perform the download.

What I have learned is that if I don't download, everything works fine. Apparently the NSURL is putting NSPorts and what not in the worker thread's run loop, and so the run loop does not exit after I invalidate all of the ports and connections that I have created myself. I don't mind the NSURL putting ports in there, but it annoys me that they apparently aren't removed.

One solution I have is to use the methods which iterate the run loop one iteration at a time, in a while loop, instead of the convenience "run" method. I set a BOOL flag to exit the while loop when I am finished. But this isn't a very elegant solution, because it is possible that someone may actually put something in the run loop deliberately, and my solution ignores this possibility, exiting the thread.

Is there a nice way out of this?
Would NSURL's behavior classify as a bug?
Is there any way to clean up the NSRunLoop of the mess that NSURL leaves behind?

Drew

========================================
Dr. Drew McCormack (Kmr. R153)
Afd. Theoretische Chemie
Faculteit Exacte Wetenschappen
Vrije Universiteit Amsterdam
De Boelelaan 1083
1081 HV Amsterdam
The Netherlands

Email email@hidden
Telephone +31 20 44 47623
Mobile +31 6 483 21307
Fax +31 20 44 47629
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: NSRunLoop and NSURL
      • From: Cameron Hayne <email@hidden>
  • Prev by Date: Read only NSMutableArray after unarchiving
  • Next by Date: Re: NSRunLoop and NSURL
  • Previous by thread: Re: Read only NSMutableArray after unarchiving
  • Next by thread: Re: NSRunLoop and NSURL
  • Index(es):
    • Date
    • Thread