Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/assembly/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用Silverlight时内存泄漏';MVVM应用程序中的s时间选择器_Silverlight_Windbg_Mvvm Light_Silverlight Toolkit - Fatal编程技术网

使用Silverlight时内存泄漏';MVVM应用程序中的s时间选择器

使用Silverlight时内存泄漏';MVVM应用程序中的s时间选择器,silverlight,windbg,mvvm-light,silverlight-toolkit,Silverlight,Windbg,Mvvm Light,Silverlight Toolkit,在我们的Silverlight MVVM应用程序中,我们在Silverlight工具包时间选择器上苦苦挣扎了一段时间。使用它将停止使用时间选择器进行垃圾收集的视图。当我打开和关闭同一视图5次时,内存中有该视图的5个副本 以前,我们在MVVM_指示灯的KeyTriggers中遇到过内存泄漏问题:EventToCommand inside。通过使用KeyTrigger的名称在代码隐藏中分离触发器,解决了此问题 使用WinDbg工具,我们可以看到关闭视图后,时间选择器在视图(当然还有ViewModel

在我们的Silverlight MVVM应用程序中,我们在Silverlight工具包时间选择器上苦苦挣扎了一段时间。使用它将停止使用时间选择器进行垃圾收集的视图。当我打开和关闭同一视图5次时,内存中有该视图的5个副本

以前,我们在MVVM_指示灯的KeyTriggers中遇到过内存泄漏问题:EventToCommand inside。通过使用KeyTrigger的名称在代码隐藏中分离触发器,解决了此问题

使用WinDbg工具,我们可以看到关闭视图后,时间选择器在视图(当然还有ViewModel)上提供了引用。 我现在的问题是,是否有可能以某种方式分离特定计时器的键触发器来解决此问题?或者,如果有人已经有使用计时器的经验,有没有其他方法可以防止内存泄漏

谢谢你的帮助

PS:这是WinDbg的输出!一个视图的gcroot命令:

    DOMAIN(07E099E8):HANDLE(Pinned):39b12f8:Root:  0bd74260(System.Object[])->
  0ad8a2d0(System.Collections.Generic.Dictionary`2[[System.IntPtr, mscorlib],[System.Object, mscorlib]])->
  0c0dc6e8(System.Collections.Generic.Dictionary`2+Entry[[System.IntPtr, mscorlib],[System.Object, mscorlib]][])->
  0b6fa01c(System.Windows.Controls.Border)->
  0b6fa080(System.Collections.Generic.Dictionary`2[[MS.Internal.IManagedPeerBase, System.Windows],[System.Object, mscorlib]])->
      0b6fa0cc(System.Collections.Generic.Dictionary`2+Entry[[MS.Internal.IManagedPeerBase, System.Windows],[System.Object, mscorlib]][])->
  0b6f985c(System.Windows.Controls.Grid)->
  0b6f98c0(System.Collections.Generic.Dictionary`2[[MS.Internal.IManagedPeerBase, System.Windows],[System.Object, mscorlib]])->
  0b6f9f90(System.Collections.Generic.Dictionary`2+Entry[[MS.Internal.IManagedPeerBase, System.Windows],[System.Object, mscorlib]][])->
  0b6f9564(System.Windows.Controls.ContentControl)->
  0b6f97c8(System.Collections.Generic.Dictionary`2[[System.Windows.DependencyProperty, System.Windows],[System.Windows.EffectiveValueEntry, System.Windows]])->
  0b6f9814(System.Collections.Generic.Dictionary`2+Entry[[System.Windows.DependencyProperty, System.Windows],[System.Windows.EffectiveValueEntry, System.Windows]][])->
  0b6f97b4(MS.Internal.ModifiedValue)->
  0b6f9754(System.Windows.TemplateBindingExpression)->
  0b6f61a0(System.Windows.Controls.TimeUpDown)->
  0b6f874c(System.EventHandler`1[[System.Windows.Controls.UpDownParseErrorEventArgs, System.Windows.Controls.Input.Toolkit]])->
  0b49f9b4(System.Windows.Controls.TimePicker)->
  0b49fef4(System.Windows.DataContextChangedEventHandler)->
  0b49fea0(System.Windows.Data.BindingExpression)->
  0b44ff48(MyProject.ViewModel.MyViewModel)->
  0b450514(GalaSoft.MvvmLight.Command.RelayCommand`1[[System.String, mscorlib]])->
  0b707b1c(System.EventHandler)->
  0b4a7f84(GalaSoft.MvvmLight.Command.EventToCommand)->
  0b4a7c2c(System.Windows.DOCollection)->
  0b4a7bcc(System.Windows.Interactivity.TriggerActionCollection)->
  0b4a7b5c(Microsoft.Expression.Interactivity.Input.KeyTrigger)->
  0b4a4704(System.Windows.DOCollection)->
  0b4a5b8c(System.Collections.Generic.Dictionary`2[[System.Windows.DependencyObject, System.Windows],[System.Object, mscorlib]])->
  0b4a84b0(System.Collections.Generic.Dictionary`2+Entry[[System.Windows.DependencyObject, System.Windows],[System.Object, mscorlib]][])->
  0b4a7118(Microsoft.Expression.Interactivity.Input.KeyTrigger)->
  0b4a732c(System.Collections.Generic.Dictionary`2[[System.Windows.DependencyProperty, System.Windows],[System.Windows.EffectiveValueEntry, System.Windows]])->
  0b4a7378(System.Collections.Generic.Dictionary`2+Entry[[System.Windows.DependencyProperty, System.Windows],[System.Windows.EffectiveValueEntry, System.Windows]][])->
  0b70f5f4(MS.Internal.ModifiedValue)->
  0b4a2eb0(System.Windows.Controls.DataGrid)->
  0b7059e4(System.Windows.Controls.ScrollContentPresenter)->
  0b705a54(MS.Internal.Controls.ScrollData)->
  0b4a2bb8(System.Windows.Controls.ScrollViewer)->
  0b49b70c(System.Windows.Controls.Grid)->
  0b4a8b50(System.Windows.Controls.Grid)->
  0b48ebb0(System.Windows.Controls.Grid)->
  0b48ec14(System.Collections.Generic.Dictionary`2[[MS.Internal.IManagedPeerBase, System.Windows],[System.Object, mscorlib]])->
  0b492f3c(System.Collections.Generic.Dictionary`2+Entry[[MS.Internal.IManagedPeerBase, System.Windows],[System.Object, mscorlib]][])->
  0b49b4b0(System.Windows.Controls.Grid)->
  0b49b514(System.Collections.Generic.Dictionary`2[[MS.Internal.IManagedPeerBase, System.Windows],[System.Object, mscorlib]])->
  0b49b560(System.Collections.Generic.Dictionary`2+Entry[[MS.Internal.IManagedPeerBase, System.Windows],[System.Object, mscorlib]][])->
  0b493a28(System.Windows.Controls.Grid)->
  0b4947a8(System.Collections.Generic.Dictionary`2[[MS.Internal.IManagedPeerBase, System.Windows],[System.Object, mscorlib]])->
  0b4aa2f4(System.Collections.Generic.Dictionary`2+Entry[[MS.Internal.IManagedPeerBase, System.Windows],[System.Object, mscorlib]][])->
  0b498900(System.Windows.Controls.Grid)->
  0b49912c(System.Collections.Generic.Dictionary`2[[MS.Internal.IManagedPeerBase, System.Windows],[System.Object, mscorlib]])->
  0b499178(System.Collections.Generic.Dictionary`2+Entry[[MS.Internal.IManagedPeerBase, System.Windows],[System.Object, mscorlib]][])->
  0b498ad4(System.Windows.Controls.TextBox)->
  0b498b58(MS.Internal.CoreTypeEventHelper)->
  0b498d20(System.Collections.Generic.Dictionary`2[[System.Int32, mscorlib],[MS.Internal.CoreTypeEventHelper+EventAndDelegate, System.Windows]])->
  0b498d6c(System.Collections.Generic.Dictionary`2+Entry[[System.Int32, mscorlib],[MS.Internal.CoreTypeEventHelper+EventAndDelegate, System.Windows]][])->
  0b498d10(MS.Internal.CoreTypeEventHelper+EventAndDelegate)->
  0b498cd8(System.Windows.Input.KeyEventHandler)->
  0ae3cf10(MyProject.Views.MyView)

VisualStudio2010SP1支持Silverlight的评测。您可以使用此实用程序并从中获得最佳效果。

尝试使用Antz内存分析器(RedGate)并评测您的应用程序。它会给你所有你需要的信息来确定它为什么会留在内存中。可能是事件处理程序未清理


我已经用他们的分析器解决了这么多内存泄漏问题。你必须自己清理的东西太神奇了

使用特殊的
KeyTrigger
Popup
会出现内存泄漏,MS会

使用窗口时不会出现此问题