I am currently attempting to deal with an issue with releasing a FlowDocument resources. I am loading an rtf file and putting it into a FlowDocument with TextRange.Load. I n
I had previously done up #7. It was the first time I used Windbg and so I didn't know what to do with the address to find the references. Here is what I got.
Address MT Size
0131c9c0 55cd21d8 84
013479e0 55cd21d8 84
044dabe0 55cd21d8 84
total 3 objects
Statistics:
MT Count TotalSize Class Name
55cd21d8 3 252 System.Windows.Documents.FlowDocument
Total 3 objects
0:011> !gcroot 0131c9c0
Note: Roots found on stacks may be false positives. Run "!help gcroot" for
more info.
Scan Thread 0 OSTHread 47c
Scan Thread 2 OSTHread be8
Scan Thread 4 OSTHread 498
DOMAIN(001657B0):HANDLE(WeakSh):911788:Root:0131ff98(System.EventHandler)->
0131fcd4(System.Windows.Documents.AdornerLayer)->
012fad68(MemoryTesting.Window2)->
0131c9c0(System.Windows.Documents.FlowDocument)
DOMAIN(001657B0):HANDLE(WeakSh):911cb0:Root:0131ca90(MS.Internal.PtsHost.PtsContext)->
0131cb14(MS.Internal.PtsHost.PtsContext+HandleIndex[])->
0133d668(MS.Internal.PtsHost.TextParagraph)->
0131c9c0(System.Windows.Documents.FlowDocument)
DOMAIN(001657B0):HANDLE(WeakSh):9124a8:Root:01320a2c(MS.Internal.PtsHost.FlowDocumentPage)->
0133d5d0(System.Windows.Documents.TextPointer)->
0131ca14(System.Windows.Documents.TextContainer)->
0131c9c0(System.Windows.Documents.FlowDocument)
(I put it in a code block for easier reading). This is after I closed the window. So it looks like it is being referenced by a few things. Now that I know this how do I go about freeing up these references so they can release the FlowDocument.
Thanks for your help. I feel like I am finally gaining some ground.
I tried to reproduce your problem, but it doesn't happen on my machine.
Task Manager shows working set size, which isn't an accurate representation of a program's memory usage. Try using perfmon instead.
Now repeat the experiment and check if that counter keeps going up. If it doesn't, it means you aren't leaking any managed memory.