I have built a program that loads Xaml into a
, and then goes through the text sentence by sentence, using
to find words against a glossary.
, I then create
s, determined by the
, by counting from the
), and I keep these in a
I then Highlight each
in the List by using
This procedure has to be done for each sentence, so each time, I clear the
and then recalculate the
s for the next sentence.
s need to be kept in the running
in order to access the text of those ranges later).
After a lot of trial-and-error I've gotten the program to do exactly what I want, but there is a problem:
When I use it continuously for more than an hour or so, the procedure becomes progressively slower, and through some debugging I've been able to narrow the slowing part to the actual highlighting of the TextRanges.
If the program is closed and reopened, and started from the previous point, the highlighting speed is acceptable again, and predictably after an hour or so, it starts to become maddeningly sluggish again.
What I have tried:
Some things I have tried are:
1) Run.Background highlighting instead of TextBlock, i.e.
2) Reinstantiating the List instead of clearing it, i.e.
List<TextRange> ranges = new List<TextRange>();
But it seems not to have any effect in terms of progressive slowing.
What I'm wondering is, what is happening to all of those
s I've been creating along the way? I can't find any way to dispose of the old ones, so are they automatically disposed of? If not, could they be slowing things down, since presumably the
has to do heuristic calculations for each
whenever a change is made to it. Or maybe all these TextPointers are just causing memory leaks?
Is clearing the List enough to rid the
of the previous
I can't find any information on the net about what happens to
s after you're done using them...