• 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
NSNotificationCenter CPU usage problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSNotificationCenter CPU usage problem


  • Subject: NSNotificationCenter CPU usage problem
  • From: Mike Crowe <email@hidden>
  • Date: Thu, 28 May 2009 15:51:47 +0100

Hi all,
I'm running into a CPU usage problem with my Cocoa application. Basically
once the app has been running for a few hours it starts, all of a sudden, to
steadily consume an increasing amount of CPU.

On further investigation with Instruments, it seems that object allocations
seem to be the cause:

#    Object Address    Category    Creation Time    Size    Responsible
Library    Responsible Caller
26319    0x9b23e50    02:34.281    Foundation    -[NSNotificationCenter
addObserver:selector:name:object:]
26320    0x9b23e60    02:34.285    Foundation    -[NSNotificationCenter
addObserver:selector:name:object:]
26321    0x9b23e70    02:34.290    Foundation    -[NSNotificationCenter
addObserver:selector:name:object:]
26322    0x9b23e80    02:34.295    Foundation    -[NSNotificationCenter
addObserver:selector:name:object:]
26323    0x9b23e90    02:34.299    Foundation    -[NSNotificationCenter
addObserver:selector:name:object:]
26324    0x9b23ea0    02:34.302    Foundation    -[NSNotificationCenter
addObserver:selector:name:object:]
26325    0x9b23eb0    02:34.306    Foundation    -[NSNotificationCenter
addObserver:selector:name:object:]
26326    0x9b23ec0    02:34.309    Foundation    -[NSNotificationCenter
addObserver:selector:name:object:]

The screenshot below from Instruments shows the graph steadily increasing as
more and more observers are added:
http://jottle.net/Instruments.png


I am not using NSNotificationCenter directly anywhere in my application.
I've also noticed that when the app is hidden with [mainWindow
orderOut:nil]; and shown again, that the CPU usage returns to normal.


I've looked through the NSNotificationCenter docs, but haven't found
anything obvious.
I'm a novice Cocoa developer so apologies if I have overlooked something
simple.

Any help is much appreciated,
Mike.
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: NSNotificationCenter CPU usage problem
      • From: Ken Thomases <email@hidden>
  • Prev by Date: Re: Traversing an NSXML subtree
  • Next by Date: issue porting resource files code from 10.4 to 10.5
  • Previous by thread: Re: Possible to load window from nib in thread from Finder CM plugin
  • Next by thread: Re: NSNotificationCenter CPU usage problem
  • Index(es):
    • Date
    • Thread