解除viewcontroller时不会释放数据

时间:2014-04-03 04:44:31

标签: ios iphone objective-c uiviewcontroller

我使用两个按钮加载一个glkviewcontroller

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
  NSString * indentifier = segue.identifier;
  MainViewController * mvc = (MainViewController*) [segue destinationViewController];
  NSMutableDictionary * dic = [[NSMutableDictionary alloc] init];

  if([indentifier isEqualToString:@"nope"]){
    [dic setValue:[NSNumber numberWithBool:NO] forKey:@"model"];
  }
  else if([indentifier isEqualToString:@"yeap"]){
    [dic setValue:[NSNumber numberWithBool:YES] forKey:@"model"];
  }
  else{}
  [mvc startWithInfo:dic];
  myMainViewController = mvc;
}

myMainViewController具有__weak属性,仅用于跟踪内存。 MainViewController是GLKViewController的子类。 我创建了2个按钮并传递了一个字典来加载1 MainViewController,一个有代码来创建数据,另一个没有。 当我加载MainViewController时,有3个案例:

  • 在没有创建数据的情况下加载,使用的内存 15.9MB ,然后关闭 9.7MB
  • 使用创建数据加载,内存使用 53.7MB ,然后关闭 47.5MB
  • 加载创建数据后,关闭,内存电流 47.5MB 然后在没有创建数据的情况下重新加载,内存恢复为 16MB

我使用myMainViewController和__weak属性来跟踪内存并识别所有控制器和属性在解除后释放。这似乎是记忆"缓存"或者"延迟"发布。 我很困惑。 任何正文都会帮我解除viewcontroller并立即释放所有数据。 感谢

0 个答案:

没有答案
相关问题