AvalonEdit icon indicating copy to clipboard operation
AvalonEdit copied to clipboard

Memory leak when programatically setting the cursor position

Open agentS opened this issue 6 years ago • 0 comments

Hi,

First of all, thank you for your great text editor. I'm using it for building a debugger for embedded systems with multiple windows showing source code that can be opened and closed dynamically. Each editor window consists of the Avalon editor and some buttons and text fields for searching and navigating. Being a debugger for embedded systems I need to move the caret to the position of a changed variable once a value changes.

When closing an editor window I, of course, want to dispose all resources. However, the following lines for moving the editor to build up an undo stack which is not disposed:

TextLocation newCursorPosition = new TextLocation
(
    manipulated.Line,
    manipulated.avalonEditor.TextArea.Caret.Location.Column
);
manipulated.avalonEditor.TextArea.Caret.Location = newCursorPosition;
manipulated.avalonEditor.TextArea.Caret.BringCaretToView();

dotMemory shows the following key retention paths blocking my object of being disposed (I unfortunately had to merge the screenshot using Paint.) If I remove the code shown above, the disposal of my window works fine.

Key retention paths

Thanks!

agentS avatar Sep 18 '18 15:09 agentS