• 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: Memory management, when mixing C and ObjC
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.


  • Prev by Date: Re: Memory management, when mixing C and ObjC
  • Next by Date: Re: Windows and Default Notification Center
  • Previous by thread: RE: Memory management, when mixing C and ObjC
  • Next by thread: NSSpeechSynthesizer and Volume
  • Index(es):
    • Date
    • Thread