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

Re: Re: Memory management, when mixing C and Obj C


  • Subject: Re: Re: Memory management, when mixing C and Obj C
  • From: <email@hidden>
  • Date: Fri, 23 Jul 2004 17:32:01 +0200

"Theodore H. Smith" <email@hidden> schrieb am 23.07.2004,
17:14:01:

> 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! The only thing coming close to this is the use of autorelease pools.
If you get an autorelease object back (from some method), this object
gets added to an autorelease pool (when send the autorelease message)
and when this pool is release, all the objects in the pool get send a
release message.
But still, this isn't automatic.

> 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.

I don't know REALbasic, but Objective-C doesn't have a garbage
collector, if you mean that (but Java has...)

You should read up on Objective-C memory management at Apple's site.

Regards,

Kay
_______________________________________________
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: Why can't I do commit inside Xcode?
  • Next by Date: Re: Custom NSTypesetter problems
  • Previous by thread: Re: Memory management, when mixing C and ObjC
  • Next by thread: AirTunes Details
  • Index(es):
    • Date
    • Thread