當設置一Monotouch.Dialog實例:資料 - 單 - 其他根逆參考
- 定製
UIBubbleMapElement
元件由GC設置; - 對於每個處置元素,自定義
UIBubbleMapCell
也被GC處置; - 但是對於所有處理過的單元,它們的自定義
UIBubbleMapView
都沒有處理。
要解決此問題,我開始使用Mono Profiler應用程序。
的問題是:尋找在不設置UIBubbleMapView
實例逆引用圖像。我怎麼能釋放這最後的參考,並允許收集我的自定義視圖?
最後,這是我UIBubbleMapCell
Dispose方法:
protected override void Dispose (bool disposing) {
bubbleMapView = null;
System.Diagnostics.Debug.WriteLine ("############# {0} 'Dispose' {1}.", this, disposing ? "invoked directly" : "called by the garbage collector finalizer");
base.Dispose (disposing);
}
這是我得到打印到控制檯:
############# <UIBubblesViewController: 0x152427c0> 'Dispose' called by the garbage collector finalizer.
############# <UIBubbleMapCell: 0x152b6a40; baseClass = UITableViewCell; frame = (0 195; 320 38); autoresize = W; layer = <CALayer: 0x152c65c0>> 'Dispose' called by the garbage collector finalizer.
############# <UIBubbleMapCell: 0x1524aba0; baseClass = UITableViewCell; frame = (0 35; 320 38); autoresize = W; layer = <CALayer: 0x152038f0>> 'Dispose' called by the garbage collector finalizer.
############# <UIBubbleMapCell: 0x17c91710; baseClass = UITableViewCell; frame = (0 233; 320 116); autoresize = W; layer = <CALayer: 0x152cbb80>> 'Dispose' called by the garbage collector finalizer.
############# <UIBubbleMapCell: 0x1520b2c0; baseClass = UITableViewCell; frame = (0 108; 320 52); autoresize = W; layer = <CALayer: 0x17c2fc30>> 'Dispose' called by the garbage collector finalizer.
編輯:羅爾夫感謝您的回答。
首先,我添加的下一個代碼到的UITableViewCell Dispose方法:
bubbleMapView.Dispose();
bubbleMapView = null;
雖然接收控制檯內部的下一個消息,單聲道分析器仍然呈現所述對象作爲未收集。與以前相同的圖像。
############# <UIBubbleMapView: 0x154af370; frame = (0 0; 1 1); layer = <CALayer: 0x154af0e0>> 'Dispose' invoked directly.
在API中運行時,我可以看到它的引用計數大於1。
在圖像有一個UIBubbleTextView
實例,但是它在相同的方式UIBubbleMapView
情況下的行爲完全。我的UIBubbleMapView
擁有一些其他意見。這是反向引用未檢查時的分析器信息。是否有一些技巧來處理這些子視圖?