Creating xps document with visuals collator consumes a very large amount of memory - by Greg Bachraty

Status : 


Sign in
to vote
ID 788507 Comments
Status Closed Workarounds
Type Bug Repros 1
Opened 5/23/2013 7:43:31 AM
Access Restriction Public


I'm dynamically generating long structured lists into xps using XpsDocumentWriter and VisualsToXpsDocument classes. The documents can potentially contain thousands of pages however this consumes a very large amount of memory, rapidly growing with page count. I've tracked down the excessive allocation to the XpsFixedDocumentReaderWriter, which seem to cache the contents of each page in a StringWriter even though this is never used again after the page has been committed to the package.
When I'm forcibly clearing the backing cache (clearing the StringBuilder in XpsFixedPageReaderWriter._pageStream in XpsFixedDocumentReaderWriter._pageCache with reflection, a very hackish workaround) the memory growth is much more manageable.

Also when closing/disposing the XpsDocument instance memory usage has a sudden extreme peak (regardless of the workaround above), usually 2-3x the total uncompressed size of the result document. I haven't been able to pinpoint this latter excessive usage, but I'm suspecting the packaging api pulls the entire document into memory.
Sign in to post a comment.
Posted by Cory Nelson on 4/10/2015 at 9:47 AM
Please reconsider resolving this bug. For applications encountering it, it is a showstopper.
Posted by Chipalo [MSFT] on 7/2/2013 at 9:26 AM
The WPF team has recently reviewed this issue and will not be addressing this issue as at this time the team is focusing on the bugs impacting the highest number of WPF developers. If you believe that this was resolved in error, please reactivate this bug with any necessary supporting details.

We appreciate the feedback. However, this issue will not be addressed in the next version of WPF. Thank you.
–WPF Team.
Posted by Microsoft on 5/23/2013 at 7:34 PM
Thanks for your feedback.

We are rerouting this issue to the appropriate group within the Visual Studio Product Team for triage and resolution. These specialized experts will follow-up with your issue.
Posted by Microsoft on 5/23/2013 at 7:50 AM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(