Re: [newbie] NSString code so it won't leak
Re: [newbie] NSString code so it won't leak
- Subject: Re: [newbie] NSString code so it won't leak
- From: Dean Davis <email@hidden>
- Date: Thu, 12 Sep 2002 10:23:30 -0700 (PDT)
--- Ondra Cada <email@hidden> wrote:
>
>
On Thursday, September 12, 2002, at 03:12 , Dean
>
Davis wrote:
>
>
> I even pointed out that I thought it may be
>
something to do with NSTimer
>
> but was told "Nope, wrong again."
>
>
Quite. Wrong again, indeed.
Well, I think your wrong. Utimatly part of the
behavior does involve the timer. See below.
>
> So it turns out that my example application will
>
eat
>
> memory unless it is interacted with. A timer
>
firing by
>
> itself won't trigger the code that releases (not
>
free)
>
> the standard AutoRelease pool.
>
> So this would effect any background type
>
application
>
> that relies on NSTimers to run code?
>
>
Twice nope. I've cleaned up your code a bit to see
>
what would happen with
>
just an NSTimer:
>
"Cleaned up the code"? - That's quite the
understatement. How about completely re-wrote the
whole intention of the code.
In the original code the timer event would start a
call to NSURLHandle which apparently starts a thread
to download internet data which then does a callback
to a completely different object (Fee) then the object
that started the thread (Foo). Inside the second
object (Fee) the data would be manipulated.
It seems that objects created during this manupulation
are not autoreleased unless the application is
interacted with at some future point (or forced to
AutoRelease by wrapping the code with a custom
AutoRelease Pool).
So is it the Timer causing the issue or the implicit
thread created by the NSURLHandle? It's probably the
combination of the two.
If the timer is not part of the problem then why
wouldn't the objects created during the PREVIOUS
timer-thread "loop" be released? I.E. the code would
only be retaining one set of objects and the next time
the timer fires the previous set is released in favor
of the new objects.
Because the whole stack of them autorelease by simply
clicking on the window but never released when the
timer fires.
So if interacting with the window releases the stacked
objects created by a "thread" and the timer firing
doesn't then I should modify my origianl statement and
ask that would seem to effect any application that
uses timers and threads (or maybe just NSURLHandles)
with little user interaction.
Dean
Yahoo! News - Today's headlines
http://news.yahoo.com
_______________________________________________
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.