Objective c BlogEntry上的内存泄漏在哪里?
我正在分析iPhone的iOS 4应用程序,我得到以下日志:Objective c BlogEntry上的内存泄漏在哪里?,objective-c,ios,cocoa-touch,memory-leaks,Objective C,Ios,Cocoa Touch,Memory Leaks,我正在分析iPhone的iOS 4应用程序,我得到以下日志: Leaked Object # Address Size Responsible Library Responsible Frame BlogEntry,9 < multiple > 288 Bytes Paula -[BlogViewController dataReceived] BlogEntry,1 0x9a11700 32 Bytes Paula -[BlogVi
Leaked Object # Address Size Responsible Library Responsible Frame
BlogEntry,9 < multiple > 288 Bytes Paula -[BlogViewController dataReceived]
BlogEntry,1 0x9a11700 32 Bytes Paula -[BlogViewController dataReceived]
BlogEntry,1 0x9a33e30 32 Bytes Paula -[BlogViewController dataReceived]
BlogEntry,1 0x9a44b80 32 Bytes Paula -[BlogViewController dataReceived]
BlogEntry,1 0x9a47950 32 Bytes Paula -[BlogViewController dataReceived]
BlogEntry,1 0x9a4b510 32 Bytes Paula -[BlogViewController dataReceived]
BlogEntry,1 0x9a5e840 32 Bytes Paula -[BlogViewController dataReceived]
BlogEntry,1 0x9a5e8c0 32 Bytes Paula -[BlogViewController dataReceived]
BlogEntry,1 0x9a647c0 32 Bytes Paula -[BlogViewController dataReceived]
BlogEntry,1 0x9a74ee0 32 Bytes Paula -[BlogViewController dataReceived]
bloggentry.m
#import "BlogEntry.h"
@implementation BlogEntry
@synthesize title;
@synthesize text;
@synthesize date;
@synthesize photo;
- (id)initWithTitle:(NSString*)titulo
text:(NSString*)texto
date:(NSDate*)fecha
photo:(NSString*)foto
{
if (self = [super init])
{
title = [titulo copy];
text = [texto copy];
date = [fecha retain];
photo = [foto copy];
}
return self;
}
- (void) dealloc
{
[title release];
[text release];
[date release];
[photo release];
[super dealloc];
}
@end
你知道我的内存泄漏在哪里吗?我找不到它。你应该看看
静态分析器。它会告诉你出了什么问题
blogEntries = [[NSMutableArray alloc] initWithCapacity:data.count];
请参阅本文档中的“查找编码错误”
:
…或者自己试试:在XCode中按Product>Analyze
#import "BlogEntry.h"
@implementation BlogEntry
@synthesize title;
@synthesize text;
@synthesize date;
@synthesize photo;
- (id)initWithTitle:(NSString*)titulo
text:(NSString*)texto
date:(NSDate*)fecha
photo:(NSString*)foto
{
if (self = [super init])
{
title = [titulo copy];
text = [texto copy];
date = [fecha retain];
photo = [foto copy];
}
return self;
}
- (void) dealloc
{
[title release];
[text release];
[date release];
[photo release];
[super dealloc];
}
@end
blogEntries = [[NSMutableArray alloc] initWithCapacity:data.count];