首页 \ 问答 \ ARC下没有发布内存(Memory is not released under ARC)

ARC下没有发布内存(Memory is not released under ARC)

我有一个带有父视图控制器的应用程序。 它有一些按钮,当单击其中一个按钮时,它会显示一个模态视图控制器(使用XIB)。 我用来呈现和解散Modal VC的代码是:

iPadViewController *iPadVC = [[iPadViewController alloc] initWithNibName:nil bundle:nil];
        [self presentViewController:iPadVC animated:YES completion:NULL];

并解雇:

-(IBAction)Back:(id)sender{
[self.presentingViewController dismissViewControllerAnimated:YES completion:nil];
}

所以问题是,当我解雇它时,它不会释放任何内存。 如果我把它呈现3/4次就会崩溃。 我正在使用ARC,从来没有遇到过类似的问题,因为我坚持认为ARC完成了所有的内存管理工作。 我确实有一些需要大量空间的背景,他们也没有被释放。 我试过了 :

[backgroundImage removeFromSuperview];
backgroundImage=nil;

使用此代码确实减少了内存,我不确定图像是否已被释放,因为下次按下按钮时内存增加到近300mb并因“内存压力”而终止。 如果VC被发布它可以正常工作,因为它在iPad上只使用160mb,在iPhone上只使用65mb。 此外,我的图像是通过Xib实用程序选择的:

IMG http://i42.tinypic.com/2z8yiva.png

我尝试使用Xcode仪器并且它没有显示任何泄漏(!)但它确实表明每次单击按钮时分配都在增长和增长。

使用Xcode Tools分配http://i43.tinypic.com/2eutv78.png

在我的ViewController.h上:

IBOutlet UIImageView (...);
IBOutlet UIImageView (...);
IBOutlet UILabel (...);
IBOutlet UIButton (...);
IBOutlet NSTimer (...);
IBOutlet UIImage (...);
IBOutlet UIView (...);

-(IBAction)Back:(id)sender;

@property (nonatomic, assign) int ;
@property (nonatomic) IBOutlet UIButton ;
@property (nonatomic) IBOutlet UIButton ;
@property (nonatomic) IBOutlet UIButton ;
@property (nonatomic) IBOutlet UIView ;
@property (nonatomic) IBOutlet UILabel ;

我试图提供有关我的代码的所有详细信息,但如果您还需要其他任何内容,请告诉我,并非常感谢您!


I have an app with a parent View Controller. It has some buttons and when one of them is clicked it presents a Modal View Controller (using XIB). The code I use to present and dismiss the Modal VC is :

iPadViewController *iPadVC = [[iPadViewController alloc] initWithNibName:nil bundle:nil];
        [self presentViewController:iPadVC animated:YES completion:NULL];

and to dismiss :

-(IBAction)Back:(id)sender{
[self.presentingViewController dismissViewControllerAnimated:YES completion:nil];
}

So the problem is, when I dismiss it, it does not release any memory. And if I present it 3/4 times it crashes. I am using ARC, never had similar problems because I tough that ARC did all the memory management job. I do have some backgrounds that need a lot of space and they are not getting released either. I tried :

[backgroundImage removeFromSuperview];
backgroundImage=nil;

The memory does decrease using this code, I'm not sure if the image was released because the next time I press the button the memory increases to almost 300mb and terminates due to "memory pressure". If the VC was released it would work fine because it only uses 160mb on the iPad and 65mb on the iPhone. Also, My image is selected through the Xib utilities :

IMG http://i42.tinypic.com/2z8yiva.png

And I tried to use Xcode instruments and it does not show any leak (!) but it does show that the allocations are growing and growing every time I click a button.

Allocations with Xcode Tools http://i43.tinypic.com/2eutv78.png

and on my ViewController.h:

IBOutlet UIImageView (...);
IBOutlet UIImageView (...);
IBOutlet UILabel (...);
IBOutlet UIButton (...);
IBOutlet NSTimer (...);
IBOutlet UIImage (...);
IBOutlet UIView (...);

-(IBAction)Back:(id)sender;

@property (nonatomic, assign) int ;
@property (nonatomic) IBOutlet UIButton ;
@property (nonatomic) IBOutlet UIButton ;
@property (nonatomic) IBOutlet UIButton ;
@property (nonatomic) IBOutlet UIView ;
@property (nonatomic) IBOutlet UILabel ;

I tried to give all the details about my code, but if you need anything else just let me know, and thank you all so much!


原文:https://stackoverflow.com/questions/20310304
更新时间:2023-04-02 22:04

最满意答案

  • 当你释放/部署时,标记是一个不错的主意。
  • 当您只想为自己添加书签时,您可以使用本地标签。
  • 当您需要指定特定修订版本时,例如在错误报告或电子邮件中,只需使用变更集标识符,它很长,但您可以缩短它。

  • When you release/deploy, it is a nice idea to tag.
  • When you just want a bookmark for yourself, you can use a local tag.
  • When you need to specify a specific revision, for example in a bug report or an email, simply use the changeset id, it is long but you can shorten it.

相关问答

更多
  • 你可能需要类似ConvertExtension的东西。 查看--splicemap选项。 使用添加为.hgignore文件的第一个修订版创建新历史记录: 创建一个新的存储库,其唯一版本是.hgignore提交。 创建一个包含两个40字符散列的splicemap文件:当前数据库的rev 0和新数据库的rev 0。 运行hg convert --splicemap splice_filename 这将当前数据库中的每个修订添加到新数据库。 splice ...
  • Tonfa是对的 你所描述的不是“合并”(或“推”或“拉”); 这是“樱桃采摘”。 推或拉将所有更改集从一个repo移动到另一个还没有在该备份中。 “合并”需要两个“头”,并将它们合并到一个新的变更集,它们是两者的组合。 如果你真的需要移动G,但是不能在D,E,F那里存在,那么你应该从repo A中“hg export”G,然后在repo A中“hg import”它。 移植扩展是一个包装导出/导入一些细节,以帮助避免多次移动相同的变更集。 然而 ,一般来说,使用导入/导出,移植和樱桃采集的缺点是,如果没有 ...
  • 你可以用hg cat : hg cat -r revisionid filename > tmpfile You can use hg cat: hg cat -r revisionid filename > tmpfile
  • 您可以使用mate -从stdin读取。 所以你可以使用hg cat filename -r rev | mate - hg cat filename -r rev | mate - 。 但是,默认情况下会启用TextMate Mercurial包,因此如果您已在TextMate中查看该文件,请使用Bundles > Mercurial > View Revision (或⌘Y6 )来选择要查看的旧版本。 You can use mate - to read from stdin. So you can u ...
  • 在这种情况下,这可以毫无困难地完成。 有关详细信息,请参阅Mercurial指南中的删除历史记录 。 以下是您需要做的基础知识: 转到local_clone2 从当前号码获取修订号( hg tip将显示)。 我们称之为731。 hg export 730-731 > ../local_clone1/changes.diff (或者你喜欢的地方) 转到local_clone1 hg import changes.diff 您可能需要手动编辑内容; 在这种情况下,请参阅该指南以获取更多信息。 This can ...
  • 当你释放/部署时,标记是一个不错的主意。 当您只想为自己添加书签时,您可以使用本地标签。 当您需要指定特定修订版本时,例如在错误报告或电子邮件中,只需使用变更集标识符,它很长,但您可以缩短它。 When you release/deploy, it is a nice idea to tag. When you just want a bookmark for yourself, you can use a local tag. When you need to specify a specific rev ...
  • 在.hgsub文件中,您可以使用http://[user[:pass]@]host[:port]/[path][#revision] (或local/filesystem/path[#revision] )语法(参见hg help urls获取更多示例)将subrepo锚定到特定修订版。 对于该修订字符串,您甚至可以使用#branchname或#tagname以便跟踪特定分支(ex stable )或可移动标记(例如: release )的提示,以便在分支或标记上时仅获取新版本远程子参数更新。 (copie ...
  • 如果你没有任何失去的工作,你可以说: hg update -c -r REV 这表示更新到修订版REV(一个数字),并丢弃我所有的任何未提交的更改。 此外,hg已经拥有了一个命令,特别是试图找到一些东西被破坏的变化。 hg bisect 这里有一章介绍它 。 if you don't have any work to lose then you can say: hg update -c -r REV That says update to revision REV (a number), and ...
  • 这不是预期的行为,你点击了Bug 1839 。 This is not the intended behavior, you hit Bug 1839.
  • 如果您正在寻找错误,请查看bisect命令。 此命令有助于查找引入问题的变更集。 要使用,请将您知道的最早变更集标记为问题,然后将最新变更集标记为没有问题。 Bisect会将您的工作目录更新为修订版以进行测试(除非指定了-U / - noupdate选项)。 一旦执行了测试,将工作目录标记为好或坏,并且bisect将更新为另一个候选变更集或宣布它已找到错误的修订。 After much hunting, I think the best solution really is to use tags. The ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)