When I use c# to read a .xps file, I get an OutOfMemoryException
.
I got some information from Opening XPS document in .Net causes a memory leak, but it seems not work in my code.
My Code below:
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();
}
- When I remove the line
fixedPage.UpdateLayout()
. Through Win8's "Task Manager", the current program's use of memory increased 10MB each time while I read one .xps file. - When I add this line, the use of memory still increased about 1MB each time.
Any one can help me?