MonoTouch/MT Garbage Collector: how to correctly release my views/class members (simple example)?

后端 未结 2 1107
被撕碎了的回忆
被撕碎了的回忆 2021-01-13 17:19

Have a look at the sample below which is not completely implemented but demonstrates what I\'m talking about:

public class MyClass : UIView
{
  private UIVie         


        
2条回答
  •  渐次进展
    2021-01-13 17:30

    I would just reuse your SubView instead of making a new one each time. So create it in ViewDidLoad, store it in a member variable, and reuse it.

    I don't think the extra memory will be a problem, and you won't have to worry about the GC at all.

提交回复
热议问题