Re: [NSString stringWithContentsOfURL:...], threads, and 10.5.4, xcode 3.1
At 7:50 AM -0400 7/22/08, Kyle Sluder wrote: On Mon, Jul 21, 2008 at 5:02 PM, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: NSString* csvString = [NSString stringWithContentsOfURL: lookupURL encoding: NSUTF8StringEncoding error: &lookupError]; This line right here requires an autorelease pool. Have you created one for your thread? It's apparent that you have a memory management issue somewhere in your code. Can you post more context? --Kyle Sluder kyle, thanx for the reply. yes, i do have an autorelease pool in place. i agree that it looks like some kind of memory management problem. the "bothersome" aspect is that this code used to work without any problems. and yes, i know thread problems aren't always reproducible, but the code has been in use problem free for sometime, probably going back as far as 10.5.3 or earlier. but i can't figure out what CFURL/NSURL is causing the problem. i'm not sure exactly what additional code is worth posting. given (what i believe is the relavent code): NSURL* lookupURL = [[NSURL alloc] initWithString: urlLookupString]; NSError* lookupError = nil; NSString* csvString = [NSString stringWithContentsOfURL: lookupURL encoding: NSUTF8StringEncoding error: &lookupError]; ... [lookupURL release]; the error occurs during the processing of stringWithContentsOfURL; i would assume that it would retain the passed in url as long as it needs it; and i retain it (alloc init) before making the call and don't release the url until after my call to stringWithContentsOfURL. ken ___ 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 [EMAIL PROTECTED]
Re: [NSString stringWithContentsOfURL:...], threads, and 10.5.4, xcode 3.1
On Mon, Jul 21, 2008 at 5:02 PM, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: >NSString* csvString = [NSString stringWithContentsOfURL: lookupURL > encoding: NSUTF8StringEncoding error: &lookupError]; This line right here requires an autorelease pool. Have you created one for your thread? It's apparent that you have a memory management issue somewhere in your code. Can you post more context? --Kyle Sluder ___ 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 [EMAIL PROTECTED]
[NSString stringWithContentsOfURL:...], threads, and 10.5.4, xcode 3.1
i have been using +[NSString stringWithContentsOfURL:encoding:error:] in my app to obtain stock quotes from yahoo. i issue this in one (or more) threads to get values for one (or more) stocks. i'm not quite sure when this stopped working successfully, but it is definitely not working reliably on 10.5.4 with xcode 3.1 and with NO garbage collection. by not reliably i mean that i will quite frequently (but not always) get the following message on the console: *** -[CFURL _cfurl]: message sent to deallocated instance 0x290180d0 and the relevant stack trace is: #0 0x95ae3907 in ___forwarding___ #1 0x95ae3a12 in __forwarding_prep_0___ #2 0x95ab5d42 in CFURLCopyPath #3 0x92350d4e in createNotificationName #4 0x9235113c in __PrivateCookieStorageDeallocate #5 0x95a66788 in _CFRelease #6 0x923510d6 in __CFHTTPCookieStorageDeallocate #7 0x95a66788 in _CFRelease #8 0x92306c2d in _CFURLRequestDeallocate #9 0x95a66788 in _CFRelease #10 0x9230ac1b in __CFCachedURLResponse::SetRequest #11 0x9230ab0e in AddCacheTask #12 0x92308603 in __CFURLCache::CopyResponseForRequest #13 0x92307b38 in _CFURLConnectionSendCallbacks #14 0x92307573 in muxerSourcePerform #15 0x95a64615 in CFRunLoopRunSpecific #16 0x95a64cf8 in CFRunLoopRunInMode #17 0x9232ab42 in CFURLConnectionSendSynchronousRequest #18 0x952ac80b in +[NSURLConnection sendSynchronousRequest:returningResponse:error:] #19 0x9537afab in -[NSString initWithContentsOfURL:encoding:error:] #20 0x9537a51f in +[NSString stringWithContentsOfURL:encoding:error:] #21 0x00147f00 in +[StockSupport_Yahoo(PrivateUtilities) historicStockValue:asOfDate:error:] at StockSupport_Yahoo.mm:296 and the relevant snippet of my code is: NSURL* lookupURL = [[NSURL alloc] initWithString: urlLookupString]; NSError* lookupError = nil; NSString* csvString = [NSString stringWithContentsOfURL: lookupURL encoding: NSUTF8StringEncoding error: &lookupError]; ... [lookupURL release]; i've worked around it for the time being by actually calling +[NSString stringWithContentsOfURL:encoding:error:] from my main thread, but not only does this slow down the app (since requests are now sequential), but it also prevents the user from aborting the requests (since the main/ui thread is now busy). can anyone explain the above error? can anyone indicate whether or not +[NSString stringWithContentsOfURL...] is thread safe? (i was under the impression that the foundation classes NSString, NSURL, and NSData were all thread safe, and as i said above, this used to work.) thanx for any help/answers/advice/etc. thanx, ken ps. it would take a fairly significant restructuring to use asynchronous NSURLConnection requests, so i'd like to avoid that if possible... especially since i had thought i had solved this problem by performing the requests in threads. ___ 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 [EMAIL PROTECTED]