• 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
Notifications and memory management
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Notifications and memory management


  • Subject: Notifications and memory management
  • From: Jay Kuri <email@hidden>
  • Date: Sat, 30 Mar 2002 12:45:38 -0600

Hi there,

I have a question regarding Notifications. I have scoured the docs but I have not found an answer to this one.

When one of my objects sends a notification with userInfo, and multiple objects receive it, who, if anyone, is responsible for releasing it?

From what I understand, when you send a Notification with userInfo this happens:

1) the userInfo dictionary itself retains the objects placed in it
2) the Notification retains the userInfo dictionary

what I do not understand is, if I send a notification and multiple objects receive it... what happens memory-wise?

The object's I'd be placing in the userInfo are not needed by the sending object after the notification is sent. So, I intend to autorelease them. Since the userInfo Dictionary retains them, I feel confident that the recipients of the notification will receive them intact. However, I don't understand how long they will be valid.

Is the notification itself autoreleased? Does that mean that I have everything in the
notification object only until my recipient method exits (or I retain notification?)

Basically what I'm trying to determine is:
1) do I need to retain the object from the userInfo dictionary if I want to keep it?
2) if I don't retain it, how long can I expect to have a valid object?
3) When do Notifications get released? Is it automatic?

Thanks for any help or pointers!

Jay
_______________________________________________
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: Notifications and memory management
      • From: Greg Titus <email@hidden>
  • Prev by Date: Animated GIFs?
  • Next by Date: Re: NSView subclass never gets dealloced?
  • Previous by thread: Re: Animated GIFs?
  • Next by thread: Re: Notifications and memory management
  • Index(es):
    • Date
    • Thread