Re: String memory leak
Re: String memory leak
- Subject: Re: String memory leak
- From: Bruce Truax <email@hidden>
- Date: Sat, 01 Apr 2006 17:11:17 -0500
- Thread-topic: String memory leak
On 4/1/06 10:56 AM, "Peter Robinson" <email@hidden> wrote:
> It's not obvious to me why you're apparently leaking an NSCFString each
> time, but you're certainly causing an instance of /ACSurface/ to be
> leaked (later) after every invocation of -GLASS. You need to -release
> the original aSurface instance just before you trash your reference to
> it in the last line of that method. The array will look after its own
> reference to aSurface.
>
> In other words, do this:
>
> - (void)GLASS:(NSString *)parameterString
> {
> [aSurface setGlass:[NSString stringWithFormat:
> @"GLASS %@", parameterString]];
> [aSurface setSurfaceNumber:surfaceNumber];
> surfaceNumber++;
> [surfaceArray addObject:aSurface];
> [aSurface release]; // <-----------
> aSurface = [[ACSurface alloc]init];
> }
That is exactly what I thought but when I release aSurface as you show my
program crashes because the pointer in surfaceArray is corrupted. Perhaps I
have another problem earlier in the code which is causing this problem.
Bruce
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden