Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
20
Bug? Memory leak and decreasing performance
posted

Hello.

I'm using the Drag & Drop framework with many DragSources and many DropTargets.
These are regularily newly instantiated when the user is filtering or updating a list of elements of which each element is a DragSource that can be dragged onto a list of DropTargets.
When the list of DropTargets which is a list of UserControls is cleared and refilled I'm using the Unload event of the UserControl to set IsDropTarget = false. This makes the DragDropManager unregistering the DropTarget as expected. When trying the same with IsDraggable on the DragSources the DragDropManager does not unregister the DragSource properly an keeps on holding a reference in its internal list. So the internal list is constantly growing and the drag drop experience gets more and more stuttering.

After I downloaded the source code an changed UnregisterDragSource to:

protected internal static void UnregisterDragSource(UIElement element)
{
   if (element != null)
   {
      element.RemoveHandler(
UIElement.MouseLeftButtonDownEvent, new MouseButtonEventHandler(OnMouseLeftButtonDown));

      if
(Instance._dragSources.Contains(element))
      {
         Instance._dragSources.Remove(element);
      }
   }
}

changed the internal list of DragSources is cleaned up as I would expect it.
Is your implementation a bug? Or is it by design and I'm missing something?
Best regards
Holger

Parents
No Data
Reply Children