• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: String memory leak
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: String memory leak


  • Subject: Re: String memory leak
  • From: Bruce Truax <email@hidden>
  • Date: Sat, 01 Apr 2006 08:27:32 -0500
  • Thread-topic: String memory leak



On 4/1/06 8:15 AM, "Julio Cesar Silva dos Santos" <email@hidden>
wrote:

> 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.

When it executes the GLASS method this marks the end of all of the
information needed to define aSurface.  At that point I add it to the
surfaceArray and then initialize a new one which I then fill the next time
through the loop.

Bruce

>
> 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:
>
> This email sent to email@hidden

--
____________________________________________________________
Bruce E. Truax                 email:  email@hidden
Optical Engineering Consultant

             Diffraction Limited Design LLC
388 Wedgewood Road             voice:  860-276-0450
Southington, CT  06489         fax:    860-620-9026
http://www.dld-llc.com
_____________________________________________________________


 _______________________________________________
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

  • Follow-Ups:
    • Re: String memory leak
      • From: "Chris Lewis" <email@hidden>
References: 
 >Re: String memory leak (From: Julio Cesar Silva dos Santos <email@hidden>)

  • Prev by Date: Re: String memory leak
  • Next by Date: Re: String memory leak
  • Previous by thread: Re: String memory leak
  • Next by thread: Re: String memory leak
  • Index(es):
    • Date
    • Thread