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 06:12:15 -0700 (PDT)
Funny, after Jim's "Buddy, your code isn't leaking
everyone in the world had told you this and you choose
to ignore this so your a bone-head" post last night I
really gave up on the thread and the list.
In several posts I pointed out that I never believed
that the NSString stuff was really leaking but I
couldn't figure out why ObjectAlloc was showing me
leaks so I was turning to the list to point out
something that as a newbie I would have missed.
What did I get? The standard, go read the books and
the web sites. The memory management rules are so easy
a monkey with half a brain could figure them out. I
even pointed out that I thought it may be something to
do with NSTimer but was told "Nope, wrong again."
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?
Another funny was I figured this out last night. The
problem was that I would start ObjectAlloc which would
start my app. I would start the timer in my app and
switch back to ObjectAlloc which would make my program
in the background and the objects would start to pile
up. The light bulb was that during this process I
finally clicked my application to the foreground and
everything released (and as a result were freed).
My real program is actually a background application
that runs on a timer only. So last night I did wrap
everything around my own AutoRelease pools and
everything cleared up as predicted.
Thanks to those who finally went a step beyond the
obvious and got down to the bottom of this.
Dean Davis
--- Charles Srstka <email@hidden>
wrote:
>
On Wednesday, September 11, 2002, at 10:59 PM,
>
Shawn Erickson wrote:
>
>
> The issue appears to be that the autorelease pool
>
that they are being
>
> put into is _not_ being released... I did wrap the
>
call to [self
>
> extractWithData:[sender resourceData]]; with an
>
autorelease pool an
>
> the leaks went away...
>
>
That's what I thought. Okay, Dean, now you have a
>
simple solution to
>
your problem - wrap the code inside an autorelease
>
pool, as I described
>
in my previous message in this thread.
>
>
Charles
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.