A WPF TextPointer can point to a text element or to a position in the text of a Run. For example, if you have
<Paragraph><Run>Hello</Run><Paragraph>
and
TextPointer p = document.ContentStart.GetNextInsertionPosition(LocalDirection.Forward);
p will point between "H" and "e".
So far so good.
However, this increments a reference count to an internal splay tree node. This reference count it is never decremented. In other words, if you traverse the document character by character, this will create a splay tree node for each character and never merge.
Is there a way to free the text pointer so that we merge the splay tree node?