English 中文(简体)
NSXMLParser memorytle on theios 4.0 - ** NOT**
原标题:NSXMLParser memory leak on ios 4.0 - **NOT** NSCFString

I m 在其进行后从记忆中释放出,在我的NSXMLParser中发现一片 we脏的泄漏。

它是在NSMapTable alloc泄漏的情况下发生的。 在此,我要指出:

   0 libSystem.B.dylib calloc
   1 libobjc.A.dylib _internal_class_createInstanceFromZone
   2 libobjc.A.dylib class_createInstance
   3 Foundation NSAllocateObject
   4 Foundation +[NSMapTable alloc] <===== this is the leak...
   5 Foundation -[NSXMLParser initWithData:]
   6 Foundation -[NSXMLParser initWithContentsOfURL:]
   7 idispatch -[RootViewController parseXML:] /Developer/iPhone  Apps/iDispatch/Classes/RootViewController.m:562 <================== this is my code calling
   8 Foundation -[NSThread main]
   9 Foundation __NSThread__main__
  10 libSystem.B.dylib _pthread_start
  11 libSystem.B.dylib thread_start

想法?

赞赏你能够展现的任何光明!

该法典:

[NSThread detachNewThreadSelector:@selector(parseXML:) 
                         toTarget:self 
                       withObject:requestStr];

采用这一方法的:

- (void)parseXML:(NSString*)theURL {
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

    NSXMLParser *parser = [[NSXMLParser alloc] initWithContentsOfURL:[NSURL URLWithString:theURL]];
    DLog(@"URL: %@",theURL);
    [parser setDelegate:self];

    [parser parse];

    [parser release];

    [pool release];
    DLog(@"xml parser thread end and released");
}
问题回答

也许太晚了,但我发现这一解决办法:

NSData * dataXml = [[NSData alloc] initWithContentsOfURL:url];
NSXMLParser *parser = [[NSXMLParser alloc] initWithData:dataXml];
[dataXml release];

而不是

NSXMLParser *parser = [[NSXMLParser alloc] initWithContentsOfURL:url];

不超过一米的泄漏......

您在释放前应重新任命该代表(报告员:无)

Same problem here. The leak appears even if I m just to this:

NSURL *xmlURL = [NSURL fileURLWithPath:[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"myfile.xml"]]; 
NSXMLParser *parser = [[NSXMLParser alloc] initWithContentsOfURL:xmlURL];
[parser release];

我先向pple子汇报,因为它在NSXMLParser班中似乎是一个严重的 b。

我也存在同样的问题,即Maloc 512 Bytes &NSConcreteMapTable Leaks......如果从Snow Leopard 10.6中汇编成文,该法典也不会泄露。

我还可以确认,以下法典适用于ios和amp;无泄漏的ma。

        NSData * dataXml = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:query]];
    NSXMLParser *parser = [[NSXMLParser alloc] initWithData:dataXml];
    [parser setDelegate:self];
    [dataXml release];
    [parser parse];
    [parser autorelease];




相关问题
Code sign Error

I have created a new iPhone application.I have two mach machines. I have created the certificate for running application in iPhone in one mac. Can I use the other mac for running the application in ...

ABPersonViewController Usage for displaying contact

Created a View based Project and added a contact to the AddressBook using ABAddressBookRef,ABRecordRef now i wanted to display the added contact ABPersonViewController is the method but how to use in ...

将音频Clips从Peter改为服务器

我不禁要问,那里是否有任何实例表明从Peit向服务器发送音响。 I m不关心电话或SIP风格的解决办法,只是一个简单的袖珍流程......

• 如何将搜查线重新定位?

我正试图把图像放在搜索条左边。 但是,问题始于这里,搜索条线不能重新布署。

热门标签