Avalon对接管理器内存泄漏

时间:2015-11-04 10:14:07

标签: c# events memory-leaks wpf-extended-toolkit

我注意到代码中存在内存泄漏 我使用Ants内存分析器来查看内存泄漏的来源 我唯一要做的就是在我的应用程序中切换标签。

我已从WPF扩展工具包2.0.0.0升级 - > 2.5.0.0但这并没有解决我的问题

这是来自蚂蚁的图表 enter image description here

有一个collectionchangedeventhandler,它有7个实例 一切都在obserablecollection<BaseViewerTabItem>

这是我的代码的一部分:

 public class ViewerBaseViewModel : ViewModelBase
    {
        protected bool IsViewerMode; // Used to identify if the image was loaded from a file to the viewer mode
        protected ImageManager _imageManager;
        private readonly IMessageBoxService _messageBoxService;
        private readonly ProgressIndicatorViewModel _progressIndicator;           
        protected ImageCollection CurrentImageCollection { get; set; }
        protected int _imageTabCounter = 1;

        private Dictionary<int, List<ImageViewerTabItem>> _groupedImages;

        public ObservableCollection<BaseViewerTabItem> OpenViewers { get; private set; }

ImageViewerTabItem类注册到OpenViewersCollectionChanged事件 如你所见,也可以从中取消注册

public ImageViewerTabItem(RelayCommand<ImageViewerTabItem> closeTabCommand, RelayCommand<ImageViewerTabItem> duplicateTabcommand, RelayCommand<AttachableItem> attachTabCommand,
            RelayCommand<ImageViewerTabItem> detachTabCommand, RelayCommand ungroupAllCommand, RelayCommand groupAllCommand, ObservableCollection<BaseViewerTabItem> openViewers, Dictionary<int, List<ImageViewerTabItem>> groupedImages)
        {
            _closeTabCommand = closeTabCommand;
            _duplicateTabcommand = duplicateTabcommand;
            _attachTabCommand = attachTabCommand;
            _detachTabCommand = detachTabCommand;
            _ungroupAllCommand = ungroupAllCommand;
            _groupAllCommand = groupAllCommand;
            OpenViewers = openViewers;
            _groupedImages = groupedImages;
            OpenViewers.CollectionChanged += OpenViewersChanged;
        }

public void TearDown()
        {
            OnTabClosed();
            OpenViewers.CollectionChanged -= OpenViewersChanged;
            ImageContentViewModel.TearDown();
        }

这是我的Xaml代码

<Grid>
        <xcad:DockingManager DocumentsSource="{Binding OpenViewers}"
                             x:Name="MainTabControl"
                             LayoutItemTemplate="{StaticResource imageSelectionTemplate}"
                             ActiveContent="{Binding ActiveTabItem, Mode=TwoWay}"
                             DocumentHeaderTemplate="{StaticResource DocumentHeaderDataTemplate}"
                             DocumentTitleTemplate="{StaticResource DocumentTitleDataTemplate}" IsHitTestVisible="True" VerticalContentAlignment="Stretch" VerticalAlignment="Stretch">
            <xcad:LayoutRoot>
                <xcad:LayoutPanel Orientation="Horizontal" >
                    <xcad:LayoutDocumentPane />
                    </xcad:LayoutPanel>
                </xcad:LayoutRoot>

        </xcad:DockingManager>
    </Grid>

你能说出我的问题所在吗? 或者如何找到内存泄漏?
Avalon dock可以有内存泄漏吗?

0 个答案:

没有答案