• 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: primitiveValueForKey Memory Management
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: primitiveValueForKey Memory Management


  • Subject: Re: primitiveValueForKey Memory Management
  • From: email@hidden
  • Date: Sun, 29 May 2005 23:22:12 +1000

I'm worried that this will result in a memory leak though.

It will, unless you explicitly take pains to release 'name' later.

What is the proper way to do this?

I'm not familiar with CoreData, but in terms of general ObjC memory management, you should technically be returning [[tmpValue retain] autorelease] (which is also what primitiveValueForKey should be returning anyway). If this doesn't work, I'd consider laying the blame on NSOutlineView, which would then be the only source of error I could see, and which is responsible for retaining "name" appropriately.


It seems unlikely your current method would fail anyway if NSOutlineView were retaining things properly... so I'm guessing NSOutlineView is either buggy, or specifies this behaviour as "caveat" in it's documentation; I'm not familiar with it so I don't know either way.

The thought does occur though that willAccessValueForKey: may alloc memory, and didAccessValueForKey: will release it... I doubt it, but just in case, you should probably do a [tmpValue retain] before you call didAccessValueForKey:, and then return [tmpValue autorelease]. Again though, this would indicate a design flaw in CoreData (or whatever these primitive key methods are), in my mind - it should be returning an autoreleased value, to avoid any such concerns in a procedural method.

Wade Tregaskis (AIM/iChat, Yahoo & Skype: wadetregaskis, ICQ: 40056898, MSN, audio/video iChat & email: email@hidden, Jabber: email@hidden)
-- Sed quis custodiet ipsos custodes?


_______________________________________________
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: primitiveValueForKey Memory Management
      • From: mmalcolm crawford <email@hidden>
    • Re: primitiveValueForKey Memory Management
      • From: Ondra Cada <email@hidden>
References: 
 >primitiveValueForKey Memory Management (From: Phil Larson <email@hidden>)

  • Prev by Date: Re: Wake from Sleep
  • Next by Date: Re: primitiveValueForKey Memory Management
  • Previous by thread: primitiveValueForKey Memory Management
  • Next by thread: Re: primitiveValueForKey Memory Management
  • Index(es):
    • Date
    • Thread