Adding and removing menu items causes memory usage to grow
Adding and removing menu items causes memory usage to grow
- Subject: Adding and removing menu items causes memory usage to grow
- From: George Nachman <email@hidden>
- Date: Wed, 27 Oct 2010 09:45:52 -0700
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 (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