On 17. 2. 2013., at 17:33, Riccardo Mottola <[email protected]> wrote:
> Hi, > > On 02/16/13 22:47, Fred Kiefer wrote: >> There is one strange thing I see in the code in ddbd.m. You don't retain the >> connection, still you release it in the -dealloc method. Most likely you >> should retain it in the -init method. Forgetting that, together with this >> code in main(): > are you sure that defaultConnection returns an autoreleased object? I thought > it to be equivalent of "new", just acting as a singleton. Since we're tracking OPENSTEP and Cocoa, I think this applies: https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/MemoryMgmt/Articles/mmRules.html Summarizing, unless the method name starts with "alloc", "new", "copy" or "mutableCopy" -- it's autoreleased (or equivalent of being autoreleased). That is, unless the method name starts with "allow", "new", "copy" or "mutableCopy" -- you don't get the ownership of the object, so you don't get the right to release it. If you want to have a right to release such an object, you need to retain it. Since the selector "defaultConnection" doesn't start with either of the strings named above, it's either autoreleased, a singleton or nil. Without looking at the code, I'd guess it's some class's class method and returns a singleton. Either way, having not been the one to instantiate the singleton (it did it itself), you can't release it. -- Ivan Vučica [email protected] - http://ivan.vucica.net/
_______________________________________________ Discuss-gnustep mailing list [email protected] https://lists.gnu.org/mailman/listinfo/discuss-gnustep
