Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: String memory leak



You have some private class (aSurface) and there is no hint on how they are created and destroyed but one thing sounds weird: the line aSurface = [[ACSurface alloc] init] was put *after* you use the object. You cannot use an object *before* creating it. I do not know if this is the problem but certainly it is not correct.

Julio Cesar Santos
email@hidden
eMac 1GHz ComboDrive
1GB RAM
Linux User #359973


On 01/04/2006, at 09:30, Bruce Truax wrote:

The command line tool "leaks" is telling me that I have an 80 byte leak of
type NSCFString everytime I execute the following method:


- (void)GLASS:(NSString *)parameterString
{
    [aSurface setGlass:[NSString stringWithFormat:
        @"GLASS %@", parameterString]];
    [aSurface setSurfaceNumber:surfaceNumber];
    surfaceNumber++;
    [surfaceArray    addObject:aSurface];
    aSurface = [[ACSurface alloc]init];

}

Here is the Leaks report:
Leak: 0x060d9410  size=80    instance of 'NSCFString'
    0xa073a674 0x0001078c 0x45474c41 0x5353204d     .s.t....EGLASS M
    0x4f44454c 0x20312e36 0x39313030 0x3230202d     ODEL 1.6910020 -
    0x312e3030 0x30303030 0x3030452d 0x30332020     1.00000000E-03
    0x302e3030 0x30303030 0x3030452b 0x30302020     0.00000000E+00
    0x302e3030 0x30303030 0x3030452b 0x30300054     0.00000000E+00.T

I assume that I am doing something wrong with memory management in the line:

   [aSurface setGlass:[NSString stringWithFormat:
        @"GLASS %@", parameterString]];

Should I be using the following instead?

  [aSurface setGlass:[[NSString alloc] initWithFormat:
        @"GLASS %@", parameterString]];

This really has me puzzled.

Thanks.

Bruce
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden
References: 
 >String memory leak (From: Bruce Truax <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.