• 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
[Newbie] reference count
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Newbie] reference count


  • Subject: [Newbie] reference count
  • From: kunikyo <email@hidden>
  • Date: Fri, 16 May 2003 22:53:50 +0900

[Newbie] reference count

Hello all,

Now I am reading "Cocoa Programming" by Scott Anguish, et al.
and having a basic question about reference count that
I'm hoping people can answer.

On page 223〜page 272, I have found following two questions on a sample program.

I traced the opening sequence and found successive allocWithZone twice, and
_myOpenDocuments is not released after the Quit of the sample program.

The first question is about the following message.
_myOpenDocuments = [[NSMutableArray allocWithZone:[self zone]] init];

This message is called in -init and -awakeFromNib, so this message is called
twice at the opening sequence.

Is it permitted that allocWithZone of the same array is called twice?
Reference count kept 1 after twice call of allocWithZone.

I think that we need allocWithZone of -awakeFromNib but
we do not need allocWithZone of -init.
The allocWithZone of -init does not make sense to me.


The second question is that _myOpenDocuments was not released
after all.

We find [_myOpenDocuments release]; in - (void)dealloc,
but this was not invoked after selecting Quit on menu.
I am afraid of memory leak.

Thanks for the assistance!

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

  • Follow-Ups:
    • Re: [Newbie] reference count
      • From: "John C. Randolph" <email@hidden>
    • Re: [Newbie] reference count
      • From: publiclook <email@hidden>
  • Prev by Date: OT: WWDC
  • Next by Date: Re: Method to fill with "Aqua"
  • Previous by thread: Re: OT: WWDC
  • Next by thread: Re: [Newbie] reference count
  • Index(es):
    • Date
    • Thread