RE: Memory management, when mixing C and ObjC
RE: Memory management, when mixing C and ObjC
- Subject: RE: Memory management, when mixing C and ObjC
- From: Oliver Donald <email@hidden>
- Date: Fri, 23 Jul 2004 16:55:14 +0100
>
But doesn't Cocoa manage to handle objects without any need for
>
explicit memory management, when we are dealing with pure ObjC code? If
>
I do this:
>
>
MyClass* obj = [MyClass new];
>
obj = 0;
>
>
doesn't that call MyClass's destructor, and then free the memory? (ala
>
Java).
No, it wouldnt. You would need to do [obj release] for that to happen, and
if that takes the object's retain count to zero, [obj dealloc] would be
called. There is no garbage collection in Apple's ObjC.
>
Well, actually I was expecting "Java-like" behaviour in terms of memory
>
management, although a closer model would be REALbasic which like ObjC,
>
also uses proper refcounting.
It does use proper reference counting, but it is still manual. You can get
GC in ObjC, but not with what Apple ships with XCode.
Cheers,
Oli
DISCLAIMER: The information contained in this e-mail is confidential and may
be privileged. It is intended for the addressee only. If you are not the
intended recipient, please delete this e-mail immediately. The contents of
this email must not be disclosed or copied without the sender's consent. We
cannot accept any responsibility for viruses, so please scan all
attachments. The statements and opinions expressed in this message are those
of the author and do not necessarily reflect those of the company. The
company does not take any responsibility for the views of the author.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.