For Programmers: Free Programming Magazines  


Home > Archive > Objective C > December 2005 > Re: memory leaks (reworded so you will have no doubts on what's









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: memory leaks (reworded so you will have no doubts on what's
Sherm Pendley

2005-12-09, 7:26 pm

Santa Claus <santa@northpole.com> writes:

> // in order to stop string2 from changing when you change string1, you
> // need to do the following line which i would like to know if it's a
> // memory leak
> [string2 setString: [NSMutableString stringWithString: string1]];


The string you pass to -setString: is created with +stringWithString:.

You didn't create that string with +alloc, +allocWithZone:, +new, -copy,
or -mutableCopy, and you haven't sent it a -retain. So, you don't need
to -release or -autorelease it, and there's no leak here.

sherm--

--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com