• 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 19:47:03 -0500
  • Thread-topic: String memory leak



On 4/1/06 5:33 PM, "Peter Robinson" <email@hidden> wrote:

>> On 4/1/06 10:56 AM, "Peter Robinson" <email@hidden> wrote:
>
>>> 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.
>
> You must have.  I suggest you check all the other places you are
> assigning to the aSurface instance variable (or -releasing,
> -autoreleasing or -retaining it).  This kind of problem is exactly why
> it's a good idea to isolate this stuff in a setter method as Andy
> suggests.
>
> (I'm assuming surfaceArray is some kind of NSArray or similar.  If in
> fact it's your own code, the first place to look is in its -addObject:
> method.)

The surfaceArray object is simply an NSMutableArray, so that addObject
method is just the built in method for NSMutable Array.  I am obviously
doing something wrong so I guess it is time to go back and study the code
some more.

Thanks for all of the suggestions.

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

  • Follow-Ups:
    • Re: String memory leak
      • From: Scott Ribe <email@hidden>
References: 
 >Re: String memory leak (From: email@hidden (Peter Robinson))

  • Prev by Date: Re: Help in 2 Diamensional Array
  • Next by Date: Compare two Array
  • Previous by thread: Re: String memory leak
  • Next by thread: Re: String memory leak
  • Index(es):
    • Date
    • Thread