这是什么意思,如果垃圾收集器"更有侵略性的QUOT;在MonoTouch的4? [英] What does it mean if the garbage collector is "more aggressive" in Monotouch 4?

查看:163
本文介绍了这是什么意思,如果垃圾收集器"更有侵略性的QUOT;在MonoTouch的4?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我偶然发现这个问题:<一href="http://stackoverflow.com/questions/6037792/button-in-contentview-causes-crash-in-monotouch-runtime-bug-in-monotouch-4-0">Button在内容查看导致崩溃的MonoTouch的运行时间。臭虫的MonoTouch 4.0?并问话有问题的MonoTouch的更积极的垃圾收集器。

I stumbled about this question: Button in ContentView causes crash in MonoTouch runtime. Bug in Monotouch 4.0? and the inquirer has problems with Monotouch's "more aggressive" garbage collector.

  • 有人可以解释为什么在询价的情况下发出的错误(什么得到收集,为什么?)?
  • 什么是更积极是什么意思?什么是陷阱,我可能会落入?我应该避免?
  • 至于iOS5的:苹果iOS5的要求,应用程序将得到一个内存警告,然后它会被杀死。不同于任何其他的版本之前,在一个应用程序收到三次警告。这是什么意思了MonoTouch的?它是如何将这种行为处理?

在Xamarin团队可以总结出一些该做什么和不该做什么,并给出一个很好的解释?中也许有

Maybe one of the Xamarin team can sum up some dos and don'ts and give a good explanation?

我目前正在升级,从MT 3.2.6到4.1吨,想通过我的code和检查什么要改变。

I am currently upgrading from MT 3.2.6 to MT 4.1 and would like to go through my code and check what has to be changed.

推荐答案

我们发现有时候开发商会遇到奇怪的问题,像对话有时会停留在屏幕上,有时他们就会消失无踪,并与没有解释为什么会这样。

We found that sometimes developers would run into strange problems like dialogs would sometimes stay on the screen, and sometimes they would vanish without leaving a trace and with no explanation of why this happened.

当您创建了一个UIAlertView中,并保持它没有提到这通常发生的事情,所以就MonoTouch的关注,该对象是垃圾(你没有从code引用它,所以你没有一个使用为了它)。

This typically happened when you created an UIAlertView and kept no references to it, so as far as MonoTouch was concerned, that object was garbage (you did not reference it from your code, so you did not have a use for it).

但是对话无论是从屏幕消失立即或稍后取决于垃圾收集器的试探是否已经确定,这是时间运行集合。如果你刚刚集合后创建一个对话框,有机会,你的对话框会留在屏幕上。但如果你是非常接近的集合,或者如果你有一个后台进程占用的内存,那么GC将被触发。

But whether the dialog vanished from your screen immediately or later depended on whether the Garbage Collector's heuristics had determined that it was time to run a collection. If you had created a dialog just after a collection, chances are, your dialog would stay on the screen. But if you were very close to a collection, or if you had a background process consuming memory, then the GC would be triggered.

这一般被迷惑用户,为什么事随机消失。答案是:如果你没有保持对它的引用,GC的以为你不关心

This in general was confusing to users, "why are things vanishing randomly". The answer was: if you did not keep a reference to it, the GC assumed you did not care.

为了使这更清楚我们的用户,在调试模式在模拟器上运行MonoTouch的时候(并且有一个命令行选项来控制,对于任何版本),我们增加了上不断调用GC.Collect的模拟器线程()每隔几秒钟。这使得它更加明显,你可能没有遵守一个参照你的对话框。

To make this more clear to our users, when running MonoTouch on debug mode on the simulator (and there is a command line option to control that for any builds), we added a thread on the simulator that continuously calls GC.Collect() every few seconds. This makes it more obvious that you might have not kept a reference to a dialog of yours.

后来,我们发现了一个非常有用的和常见的模式是保持2种围绕该对话框真的没有用比他们的副作用等:UIAlertView中和UIActionSheet。我们修改的MonoTouch,使其内部不断提及这两个,直到被解散。

Later on, we found out that a very useful and common pattern was to keep two kinds of dialog boxes around that really have no use other than their side effects: UIAlertView and UIActionSheet. We altered MonoTouch so that it internally keeps references to those two until dismissed.

因此​​,我们结束了两全其美的:在开发过程中你发现先前丢失的引用,你需要的对象,而且我们注意到,仅针对其副作用有用最常见的两种情况下,护理

So we ended up with the best of both worlds: during the development cycle you catch earlier missing references to objects that you need, and we took care of the two most common cases that are only useful for their side effects.

这篇关于这是什么意思,如果垃圾收集器&QUOT;更有侵略性的QUOT;在MonoTouch的4?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆