• 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
Re: [newbie] NSString code so it won't leak
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [newbie] NSString code so it won't leak


  • Subject: Re: [newbie] NSString code so it won't leak
  • From: James DiPalma <email@hidden>
  • Date: Thu, 12 Sep 2002 03:41:39 -0400

From: Shawn Erickson <email@hidden>

This seems strange to me... I thought that NSTimers would tickle the event loop such that the current autorelease pool would be clean/dealloced after the firing on the timer.

I went back and looked at notes from playing with timers in child threads. Timers do not count as input for a run loop that is blocking; I verified that acceptInputForMode:NSDefaultInputMode untilDate:future does not return while a timer fires once per second.

I did wrap the call to [self extractWithData:[sender resourceData]]; with an autorelease pool an the leaks went away (wrapping the timer call back didn't work).

The timer call back calls [MyHandle loadInBackground] which is going to return without actually getting into extractWithData: because data is loading in a background thread.

is something mucked up in NSURL/NSURLHandle or a side effect of doing something wrong with the URL classes.

One thing you might want to try is writing a LoudFoo class that simply overrides init and release to NSLog and then call super, then alloc/init/autorelease one in extractWithData: and see if it gets released. Its an easier test than using ObjectAlloc especially since we trust substringToIndex: to autorelease the string it returns.

OK, I wrote a LoudFoo class and noticed that it does not get released while your app sits idle. A simple click anywhere in your window will generate an event that loops your NSApplication's run loop and releases LoudFoo and probably also releases your other residual objects.

Your problem is that NSRunLoop does return from a method that "runs the loop once, while blocking on input." I should have remembered this little detail.


-jim
_______________________________________________
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.

  • Prev by Date: Re: [newbie] NSString code so it won't leak
  • Next by Date: Start using Cocoa
  • Previous by thread: Re: [newbie] NSString code so it won't leak
  • Next by thread: Re: [newbie] NSString code so it won't leak
  • Index(es):
    • Date
    • Thread