开发者

NSCFString leaking when handling key events

开发者 https://www.devze.com 2023-02-22 07:21 出处:网络
I am trying to capture key presses with this code. My problem is tha开发者_StackOverflow中文版t Instruments throws a message about a leak.

I am trying to capture key presses with this code. My problem is tha开发者_StackOverflow中文版t Instruments throws a message about a leak.

I am working without Garbage Collection.

-(void)keyDown:(NSEvent *)theEvent
{
    if ([theEvent keyCode]==0)
    {
        NSLog(@"Break");
    }
}

- (BOOL)acceptsFirstResponder
{
    return YES;
}
- (BOOL)becomeFirstResponder
{
    return YES;
}
- (BOOL)resignFirstResponder
{
    return YES;
}    

Message thrown by Instruments:

Leaked Object  #   Address Size    Responsible Library Responsible Frame
NSCFString,    0x10067e540 32 Bytes    AppKit  -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:]


Look at Why is NSOpenPanel/NSSavePanel showing memory leak? and NSTextField leaking when handling key events

Your problem shows the same symptoms and it may also be a "False Positive".

Credit for this answer should go to Rob Keniger he has pointed me in the right direction.

0

精彩评论

暂无评论...
验证码 换一张
取 消