Hi cocoa-dev,

I was tracking down memory growth in my application and isolated it to
the repeated adding and removing of menu items. Doing this causes a
growth of about 1MB:

    for (int i = 0; i < 1000; ++i) {
        NSMenu *aMenu = [[NSMenu alloc] init];
        NSMenuItem* i = [[NSMenuItem alloc] initWithTitle: @"AAA"
action:nil keyEquivalent:@""];
        [aMenu addItem:i];
        [i release];
        [aMenu removeItemAtIndex:0];
        [aMenu release];
    }

The Leaks instrument doesn't show any leaks. Allocations shows a whole
bunch of different objects growing, but CFBasicHash is the worst
offender, with lots of allocations in -[NSMenu insertItem:atIndex:]
and -[NSMenu removeItemAtIndex:].

This is on OS 10.6.4. Am I doing something wrong?

Thanks,
George
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to