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

NSStatusItem memory management


  • Subject: NSStatusItem memory management
  • From: Ingmar J Stein <email@hidden>
  • Date: Sun, 5 Jun 2005 01:19:36 +0200

Hi,

the following little test program illustrates a strange problem with NSStatusItem's
memory management:


#import <Cocoa/Cocoa.h>
#import <Foundation/NSDebug.h>

static NSStatusItem *statusItem;

@interface Test : NSObject {
}
@end

@implementation Test
+ (void) applicationDidFinishLaunching:(NSNotification *)aNotification {
statusItem = [[[NSStatusBar systemStatusBar] statusItemWithLength:NSSquareStatusItemLength] retain];
[NSApp performSelector:@selector(terminate:) withObject:nil afterDelay:2.0];
}


+ (void) applicationWillTerminate:(NSNotification *)aNotification {
    [statusItem release];
}
@end

int main (int argc, const char * argv[]) {
    NSZombieEnabled = YES;
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
    [NSApplication sharedApplication];
    [NSApp setDelegate:[Test class]];
    [NSApp run];
    [pool release];

    return 0;
}

When the application terminates and the autorelease pools are released, a release message is
sent to an NSStatusBarWindow instance which has already been released:


2005-06-05 01:08:10.261 StatusItemTest[4270] *** Selector 'release' sent to dealloced instance 0x330ec0 of class NSStatusBarWindow.
Break at '-[_NSZombie release]' to debug.



Ingmar

Attachment: smime.p7s
Description: S/MIME cryptographic signature

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Prev by Date: Re: Quit Application
  • Next by Date: Using setDoubleAction with NSTableView
  • Previous by thread: Re: writeToFile:ofType:originalFile:saveOperation: on Tiger
  • Next by thread: Using setDoubleAction with NSTableView
  • Index(es):
    • Date
    • Thread