【发布时间】:2014-01-22 03:48:02
【问题描述】:
我正在从事一个大项目。直到最后一个小时都没有问题。突然间,我的应用程序的活动字节数不断增加,超过 1 GB,我什至无法确定问题出在哪里。我已经搜索并找到了this,但它是针对整体字节而不是实时字节。
五分钟后我收到以下错误:
xxxxxx(1456,0x252d1a8) malloc: *** mach_vm_map(size=8388608) failed (error code=3)
*** error: can't allocate region
这是 Instruments 的屏幕截图,您可以看到 live bytes 达到 1 GB。
我已经尝试了以下步骤
- 重置模拟器的内容和设置
- 删除 Xcode 完整的应用程序文件
- 删除所有派生文件并彻底清理垃圾
- 重新安装 Xcode
为了更正确在这行中发现错误
- (void)viewDidLoad
{
[super viewDidLoad];
[UserNameTxtFld setBackgroundColor:[UIColor colorWithRed:242.0f/255.0f green:245.0f/255.0f blue:245.0f/255.0f alpha:1.0]];
[UserPasswordFld setBackgroundColor:[UIColor colorWithRed:242.0f/255.0f green:242.0f/255.0f blue:242.0f/255.0f alpha:1.0]];
[LoginButton setBackgroundColor:[UIColor colorWithRed:60.0f/255.0f green:179.0f/255.0f blue:113.0f/255.0f alpha:1.0]];
//[ForgotButton setBackgroundColor:[UIColor lightGrayColor]];
API=[[BMAPIClass alloc] init];
API.delegate = self;
UIView *paddingView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 10, UserNameTxtFld.frame.size.height)];
UserNameTxtFld.leftView = paddingView;
UserPasswordFld.leftView =paddingView;
self.appDelegate = (BMAppDelegate*)[[UIApplication sharedApplication] delegate];
//Set Splash screen
if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
{
CGSize result = [[UIScreen mainScreen] bounds].size;
if(result.height == 480)
{
// iPhone Classic
NSLog(@"iphone 4");
if(IS_RETINA)
{
NSLog(@"Yes retina Display");
splashScreenImage.image =[UIImage imageNamed:@"splash_640x960.jpg"];
[visiblePassword setBackgroundImage:[UIImage imageNamed:@"eye_640x960.png"] forState:UIControlStateNormal];
}
else
{
NSLog(@"Not retina Display");
splashScreenImage.image =[UIImage imageNamed:@"splash_320x480.jpg"];
[visiblePassword setBackgroundImage:[UIImage imageNamed:@"eye_320x480.png"] forState:UIControlStateNormal];
}
}
if(result.height == 568)
{
// iPhone 5
NSLog(@"iphone 5");
splashScreenImage.image =[UIImage imageNamed:@"splash_640x1136.jpg"];
[visiblePassword setBackgroundImage:[UIImage imageNamed:@"eye_640x1136.png"] forState:UIControlStateNormal];
}
}
}
没有任何效果。谁能说说问题出在哪里?
【问题讨论】:
-
您是否使用 Instruments 来查看哪些对象是实时字节分配的一部分以及创建它们的代码是什么?
-
希望最近几个小时不是代码 bcz 我从来没有接触过代码我确定我在 UI 中更改了一些东西,之后只会出现这个问题
-
检查您是否不小心启用了 NSZombies。昨天我想知道为什么我的应用程序需要千兆字节的 RAM,结果我打开了 NSZombies。
-
仪器挂满了,所以我看不到是哪个对象造成了问题,无法进一步检查
-
您的代码有问题。
标签: ios memory malloc instruments