Iphone iOS 5.1中的内存泄漏

Iphone iOS 5.1中的内存泄漏,iphone,objective-c,uitableview,memory-leaks,instruments,Iphone,Objective C,Uitableview,Memory Leaks,Instruments,我只是在UIViewController中创建了一个简单的UITableView h #导入 @接口根控制器:UIViewController { NSMutableArray*_tableData; UITableView*_tableView; } @结束 m #导入“RootController.h” @根控制器的实现 -(id)initWithNibName:(NSString*)nibNameOrNil bundle:(NSBundle*)nibBundleOrNil { self=

我只是在
UIViewController
中创建了一个简单的
UITableView

h

#导入
@接口根控制器:UIViewController
{
NSMutableArray*_tableData;
UITableView*_tableView;
}
@结束
m

#导入“RootController.h”
@根控制器的实现
-(id)initWithNibName:(NSString*)nibNameOrNil bundle:(NSBundle*)nibBundleOrNil
{
self=[super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
如果(自我){
//自定义初始化
如果(!\u表数据){
_tableData=[[NSMutableArray alloc]initWithCapacity:20];
对于(int i=0;i<50;i++){
[_tabledataaddobject:[NSString stringWithFormat:@“%d”,i]];
}
}
}
回归自我;
}
-(无效)解除锁定
{
[_tableView发布];
[_表数据发布];
[super dealoc];
}
-(无效)viewDidLoad
{
[超级视图下载];
//加载视图后执行任何其他设置。
}
-(void)负荷视图
{
UIView*view=[[UIView alloc]initWithFrame:[UIScreen mainScreen].bounds];
self.view=视图;
[查看发布];
self.view.backgroundColor=[UIColor whiteColor];
如果(!\u表视图){
_tableView=[[UITableView alloc]initWithFrame:CGRectMake(0,0320460)];
_tableView.dataSource=self;
}
[self.view addSubview:_tableView];
}
-(无效)视图卸载
{
[超级视频下载];
//释放主视图的所有保留子视图。
}
-(布尔)应自动旋转指针面定向:(UIInterfaceOrientation)interfaceOrientation
{
返回(interfaceOrientation==UIInterfaceOrientationGraphic);
}
-(NSInteger)表格视图中的节数:(UITableView*)表格视图
{
返回1;
}
-(NSInteger)表视图:(UITableView*)表视图行数节:(NSInteger)节
{
返回[_tabledatacount];
}
-(UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath
{
静态NSString*cellIdentifier=@“TableViewCellIdentifier”;
UITableViewCell*单元格=nil;
cell=[\u tableView dequeueReusableCellWithIdentifier:cellIdentifier];
如果(单元格==nil){
cell=[[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault重用标识符:cellIdentifier]自动释放];
}
cell.textlab.text=[\u tableData objectAtIndex:indexath.row];
返回单元;
}
@结束
当我滚动
UITableView
,内存
泄漏发生了。

我使用Xcode 4.3.1和iOS5.1(iPod touch4)。
有人遇到了这个问题?

如果您查看“负责任的库”列,您会发现问题的根源不是您的代码。泄漏很小,你可以放心地忽略它们


这里有一个类似的问题:

如果您查看“责任库”列,您会发现罪魁祸首不是您的代码。泄漏很小,你可以放心地忽略它们


这里有一个类似的问题:

@JesusRamos,如果我的程序运行几个小时,它可能会因为内存泄漏而被系统杀死。@如果它干扰了正常的应用程序操作,请将其报告为错误。@JoshRagem Link没有显示类似的问题。它显示了相同的问题。现在更正,是相同的问题:PI也发现了相同的问题。所以我认为这是一个错误。@JesusRamos,如果我的程序运行几个小时,它可能会因为内存泄漏而被系统杀死。@Looyo如果它干扰了正常的应用程序操作,请将其报告为错误。@JoshRagem Link没有显示类似的问题。它显示了相同的问题。现在更正,是相同的问题:PI也发现了相同的问题。所以我认为这是一个错误。
#import <UIKit/UIKit.h>

@interface RootController : UIViewController <UITableViewDataSource>
{
    NSMutableArray *_tableData;
    UITableView *_tableView;
}
@end
#import "RootController.h"

@implementation RootController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
        if (!_tableData) {
            _tableData = [[NSMutableArray alloc] initWithCapacity:20];
            for (int i = 0; i < 50; i++) {
                [_tableData addObject:[NSString stringWithFormat:@"%d", i]];
            }
        }
    }
    return self;
}

- (void)dealloc
{
    [_tableView release];
    [_tableData release];
    [super dealloc];
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

- (void)loadView
{
    UIView *view = [[UIView alloc] initWithFrame:[UIScreen mainScreen].bounds];
    self.view = view;
    [view release];

    self.view.backgroundColor = [UIColor whiteColor];

    if (!_tableView) {
        _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 320, 460)];
        _tableView.dataSource = self;
    }
    [self.view addSubview:_tableView];
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return [_tableData count];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *cellIdentifier = @"TableViewCellIdentifier";
    UITableViewCell *cell = nil;
    cell = [_tableView dequeueReusableCellWithIdentifier:cellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier] autorelease];
    }

    cell.textLabel.text = [_tableData objectAtIndex:indexPath.row];

    return cell;
}

@end