FlowDocument Memory Issue in C#

前端 未结 8 1731
孤街浪徒
孤街浪徒 2021-01-02 15:34

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

8条回答
  •  难免孤独
    2021-01-02 15:57

    If I've confirmed that there's a memory leak, here's what I would do to debug the problem.

    1. Install Debugging Tools for Windows from http://www.microsoft.com/whdc/devtools/debugging/installx86.mspx#a
    2. Fire up Windbg from the installation directory.
    3. Launch your application and do the operations that leak memory.
    4. Attach Windbg to your application (F6).
    5. Type .loadby sos mscorwks
    6. Type !dumpheap -type FlowDocument
    7. Check the result of the above command. If you see multiple FlowDocuments, for each value of the first column (which contains the address), do

    Type !gcroot

    That should show you who's holding on to the reference.

提交回复
热议问题