• 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: Solving memory leaks
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Solving memory leaks


  • Subject: Re: Solving memory leaks
  • From: Michael Davey <email@hidden>
  • Date: Sun, 28 Mar 2010 18:27:31 +0100

That would be gut for the fact that my fields are released and set to nil whenever a new SELECT query is executed - however, I think I can do this by emptying the array when a new query is done and just counting the size of the array in my fetch method - thanks...

On 28 Mar 2010, at 18:11, Klaus Backert wrote:

>
> On 28 Mar 2010, at 18:40, Michael Davey wrote:
>
>>> 1. Some other piece of code assigns a new value to 'myFields' without releasing the old value.
>>
>> That is the only part of my code that adds values to the field.
>
> In order to handle your fields instance variable correctly, what do you think about the following:
>
> Create fields in the init method of your "MyClass" object (I don't know how you call this class):
>
> fields  = [[NSMutableDictionary alloc] init];
>
> by which you retain the fields dictionary.
>
> And destroy fields in the corresponding dealloc method:
>
> [fields release];
> fields = nil;
>
> If you want to use the fields dictionary anywhere in your code, you just do only calls like:
>
> [fields addObject: ...];
> [fields removeObject: ...];
> MyOtherObject *myOtherObject = [fields objectWithKey: ...];
> etc.
>
> but you do *not* invoke methods which initialize or dealloc the fields object.
>
> Klaus
>
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Solving memory leaks
      • From: Klaus Backert <email@hidden>
References: 
 >Solving memory leaks (From: Michael Davey <email@hidden>)
 >Re: Solving memory leaks (From: Michael Davey <email@hidden>)
 >Re: Solving memory leaks (From: Klaus Backert <email@hidden>)
 >Re: Solving memory leaks (From: Quincey Morris <email@hidden>)
 >Re: Solving memory leaks (From: Noah Desch <email@hidden>)
 >Re: Solving memory leaks (From: Quincey Morris <email@hidden>)
 >Re: Solving memory leaks (From: Michael Davey <email@hidden>)
 >Re: Solving memory leaks (From: Klaus Backert <email@hidden>)

  • Prev by Date: Re: Solving memory leaks
  • Next by Date: Solving memory leaks
  • Previous by thread: Re: Solving memory leaks
  • Next by thread: Re: Solving memory leaks
  • Index(es):
    • Date
    • Thread