Re: Simple memory problem
Re: Simple memory problem
- Subject: Re: Simple memory problem
- From: Sherm Pendley <email@hidden>
- Date: Fri, 6 Feb 2009 08:53:30 -0500
On Feb 6, 2009, at 8:32 AM, harry greenmonster wrote:
Yes, memory management is a weak point of mine, which I'm currently
trying to resolve. Last time I had any use for in-depth memory
management was 15 years ago.
Then you're in luck! Non-GC memory management in Cocoa is a *far*
simpler than the "in-depth" use of malloc() and free() we were doing a
decade or more ago.
It's just a few very simple design patterns. What tends to get people
in trouble with is a tendency to over-complicating matters by not
following those patterns consistently - for example, sprinkling calls
to the relevant methods throughout their code like raisins in oatmeal,
instead of encapsulating them in properly-written accessor methods.
Another common mistake is to do the above, and then make matters even
worse by attempting to debug the resulting problems by looking
directly at retain counts.
But why can the compiler not replace the data at the memory location
pointed to by the old 'inputString' without making a second pointer
(with the same name).
The compiler can't do that because assigning to a pointer and
assigning to a pointer's target are two *completely* different things,
and the programmer asked it to do the former.
C and its derivatives do what you say, not what you mean. That is a
feature, not a flaw.
sherm--
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden