WebView: libdispatch leaks in an ARC-enabled app

删除回忆录丶 提交于 2019-12-24 09:23:53

问题


In a doc-based ARC-enabled application I have a WebView that is opening an HTML file. The idea is to do some editing, and then save to WebArchive. When I run Instruments I find random leaks as in the image below. I am not initializing anything with malloc, why am I getting them? (I get the leaks when I start opening and closing windows.)

Document.h

#import <Cocoa/Cocoa.h>
#import <WebKit/WebKit.h>

@interface KBDocument : NSPersistentDocument {
    IBOutlet WebView *webView;
}

Document.m

- (void)windowControllerDidLoadNib:(NSWindowController *)aController
{
    [super windowControllerDidLoadNib:aController];

    NSString *urlStr = @"file:///Users/.........../Content/1/index.html";
    NSURL *url = [NSURL URLWithString:urlStr];

    NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
    [[webView mainFrame] loadRequest:requestObj];
    [webView setEditable:YES];
}

Leaks:


回答1:


Well, you can see that the offending library is libdispatch; so it doesn't seems that your code is in error. Libdispatch http://libdispatch.macosforge.org/ is described here. You could check it out if you want to know more.



来源:https://stackoverflow.com/questions/9612930/webview-libdispatch-leaks-in-an-arc-enabled-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!