当我使用c#读取.xps文件时,我得到OutOfMemoryException
我从Opening XPS document in .Net causes a memory leak获得了一些信息,但似乎在我的代码中无效。
我的代码如下:
using (XpsDocument document = new XpsDocument(xpsPath, System.IO.FileAccess.Read))
{
FixedDocumentSequence fds = document.GetFixedDocumentSequence();
int pageCount = fds.DocumentPaginator.PageCount;
for (int i = 0; i < pageCount; i++)
{
DocumentPage source = fds.DocumentPaginator.GetPage(i);
Visual v = source.Visual;
FixedPage fixedPage = (FixedPage)v;
fixedPage.UpdateLayout();
}
document.Close();
}
fixedPage.UpdateLayout()
时。通过Win8&#34;任务管理器&#34;,当我读取一个.xps文件时,当前程序对内存的使用每次增加10MB。 任何人都可以帮助我?