Tag: 内存pipe理

在启用ARC的项目中,为什么维护保留计数不是必需的

保留计数是在Objective-C中pipe理内存的方式。 当你创build一个对象时,它的保留计数为1.当你发送一个对象的时候,一个保留消息的保留计数会增加1,我们知道ARC会自动执行,但是它是如何执行的? ? 我仍然怀疑是否内存pipe理是自动完成的,那么为什么有时我们得到访问错误的对象分配或检索。 我已经通过这个链接: – https://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/MemoryMgmt/Articles/MemoryMgmt.html

内存使用率高

现在我有一个项目与ARC,使用超过6米的内存推聊天ViweController(UItableView自定义单元格)。 我不知道为什么发生。 最有趣的是,我不能确定它需要太多的内存是什么原因。 所以这是我的仪器截图: 更详细的看法是这样的: 我认为libRip.A.dylib需要太多的内存。 你有什么想法吗? 并请解释我是什么和奇怪的libRip.A.dylib库?

iOS:lldb EXC_BAD_ACCESS自定义单元格

– (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"LibraryListingCell"; InSeasonCell *cell = (InSeasonCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { [[NSBundle mainBundle] loadNibNamed:@"InSeasonCellView" owner:self options:nil]; cell = [_cell autorelease]; _cell = nil; } if(_dataController!=NULL){ Product *productAtIndex = [_dataController objectInListAtIndex:indexPath.row]; // Configure the cell… if (productAtIndex.name != nil && productAtIndex.week != nil && […]

内存pipe理,ARC – 什么零?

背景 – 我正在项目上使用自动引用计数。 根视图是一个表视图(主/从设置),显示“幻灯片”列表。 点击一个表格单元格,然后你被带到由一个带有视图的滚动视图(viewController.view)组成的详细视图(这是“幻灯片放映”)。 每个幻灯片放映都有一个封面和封底(相同的视图控制器格式不同),它们夹着不同数量的页面。 以下是加载幻灯片的代码: – (void)loadScrollView { // The front and back cover are set in Interface Builder because they // are reused for every slide show, just labels are changed. [self.scrollView addSubview:self.frontCoverViewController.view]; [self.frontCoverViewController setCoverTitle:_data.name creationDate:_data.creationDate isFrontCover:YES]; [self.pagesArray addObject:self.frontCoverViewController]; for (int i = 0; i < [self getTotalNumberOfComps]; i++) { PageViewController *pageView […]

如何通过asynchronous或静态调用实现强大的保留循环?

我正在努力去掌握如何才能认识到一个强大的保留周期是可能的,并要求我使用[weak/unowned self] 。 我被不必要地使用[weak/unowned self]烧毁了,在给我机会使用它之前,我自己就被释放了。 例如,下面是在闭包中引用self的asynchronousnetworking调用。 可以在这里发生内存泄漏,因为networking调用是在不将自身调用存储到variables的情况下进行的? NSURLSession.sharedSession().dataTaskWithURL(NSURL(string: url)!) { (data, response, error) in self.data = data ) 下面是使用NSNotificationCenter的另一个例子,可以稍后进行asynchronous调用: NSNotificationCenter.defaultCenter().addObserverForName( UIApplicationSignificantTimeChangeNotification, object: nil, queue: nil) { [unowned self] _ in self.refresh() } 我的问题是在什么情况下可能有强大的保留周期? 如果我在一个闭包中进行一个asynchronous调用或静态调用来引用self,是否会使它成为[weak/unowned self]的候选人呢? 感谢您排除这一点。

UIViewController在popup时不会从内存中释放

我有一个UINavigationController ,我试图从内存释放每个UIViewController一旦另一个在堆栈顶部。 我将UINavigationController的viewControllers属性分配给新的UIViewController ,然后popup。 这样我总是只有一个UIViewController在堆栈中。 但是,每当我创build一个新的UIViewController时,内存不断增加。 Dealloc被调用,但内存使用保持不变。 您可以在这里下载示例项目 FirstViewController.h #import "SecondViewController.h" @interface FirstViewController : UIViewController -(IBAction)goToSecond:(id)sender; @end FirstViewController.m #import "FirstViewController.h" @interface FirstViewController () @end @implementation FirstViewController – (void)viewDidLoad { [super viewDidLoad]; NSLog(@"%@", self.navigationController.viewControllers); } -(void)goToSecond:(id)sender{ SecondViewController *secondVC = [[SecondViewController alloc]init]; [self.navigationController setViewControllers:@[secondVC]]; [self.navigationController popViewControllerAnimated:NO]; } -(void)dealloc{ NSLog(@"FirstVC dealloc"); } @end SecondViewController.h #import "FirstViewController.h" @interface SecondViewController […]

当iPhone从睡眠状态重新开始时,取消分配,应用程序仍处于打开状态

有一些情况下,我的应用程序崩溃时,从睡眠转过来,应用程序仍然是打开的。 如果一个UITableViews在iPhone进入睡眠状态时打开, 该表正在被parsing的XML填充。 我明白为什么它崩溃了; 在我的viewDidUnload方法我释放填充表的数组。 如何处理这个我不确定; 是的,我可以简单地不释放它在viewDidUnload,但如果你返回到主菜单,它永远不会离开内存。 任何帮助,将不胜感激!

有没有办法在构build我的Cocoapod时指定另一个分支的依赖关系?

我试图build立一个Cocoapod(目前 – 这将改变当iOS 9和Xcode 7超出testing版)取决于Alamofire和SwiftyJSON的不同分支。 这是因为我的Cocoapod编码在Swift 2.0中。 更具体地说,我的pod目前依赖于swift2-0 Alamofire分支和xcode7 SwiftyJSON分支。 我的Podspecs文件目前看起来像这样: # # Be sure to run `pod lib lint ALSMAL.podspec' to ensure this is a # valid spec and remove all comments before submitting the spec. # # Any lines starting with a # are optional, but encouraged # # To learn more about […]

iOS内存pipe理问题

当您使用Xcode的function并从nib文件拖动到.h和.m文件时,Xcode将代码添加到dealloc和viewDidUnload 。 它增加了我通常不会添加的额外代码。 我只是好奇,如果这个额外的代码是必要的。 我会做[self setDisplaySlider:nil]而不是disp = nil和[disp release] 。 这是必要的吗? 我不认为你必须发布显示。 @interface ViewController : UIViewController { IBOutlet UISegmentedControl *disp; } @property (retain, nonatomic) IBOutlet UISegmentedControl *displaySlider; @end – (void)viewDidUnload { [self setDisplaySlider:nil]; [disp release]; disp = nil; [super viewDidUnload]; } – (void)dealloc { [displaySlider release]; [disp release]; [super dealloc]; }

如何处理低内存警告

在我的应用程序,我几乎下载文件后得到低内存警告。我停止当前的下载过程。 即使在这之后,应用程序崩溃,我认为应用程序崩溃,由于内存不足的问题。 任何人都可以让我知道如何在运行应用程序释放内存。