NSNotificationCenter possible memory leak? [for memory geek]
NSNotificationCenter possible memory leak? [for memory geek]
- Subject: NSNotificationCenter possible memory leak? [for memory geek]
- From: Giovanni Donelli <email@hidden>
- Date: Wed, 13 Jul 2005 14:13:28 -0700
Hi,
I can't figure out how I can get rid of the following memory
leak which is about 80KB, on my PowerBook G4.
There is something connected with the fact that 'name' is randomly
generated... however I tried for few hours to understand what was
wrong.. and here I am now to you :-)
here is the function that leads to the memory leak of about 80KB
void memoryLeak()
{
int i;
NSNotificationCenter* nc = [NSNotificationCenter defaultCenter];
for (i=0 ; i < 20; i++)
{
NSObject *obj = [NSObject new];
NSString* name = [[NSString alloc] initWithFormat:@"%
d", random()];
[nc addObserver:obj
selector:@selector(doenstMatter:)
name:name
object:nil];
[nc removeObserver:obj
name:name
object:nil];
[name release];
[obj release];
}
}
Thank you!
Giovanni Donelli
_______________________________________________
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