-
Notifications
You must be signed in to change notification settings - Fork 1.2k
XPS documents memory leak (System.Windows.ContextLayoutManager+LayoutQueue+Request and XpsDocument.GetFixedDocumentSequence()) #6301
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@gurpreet-wpf let me know if you need anything... |
I don't know if this helps @gurpreet-wpf ? 00007ffcf5b83288 407286 16291440 System.Windows.ContextLayoutManager+LayoutQueue+Request 😢
|
I really hope we are not experiencing this from 2007...: https://social.msdn.microsoft.com/Forums/en-US/9a310989-23a8-497e-b3f2-b1f2d0883bbd/memory-leak-printing-xps-files-on-aspnet?forum=windowsxps |
any updates @gurpreet-wpf ? @danmoseley ? |
Same issue with a png file exporter (oxyplot), which instantiates a LOT of :
It goes up, and up, and up -- and as it takes place in a test project, the memory is never released even between different tests when the runner runs multiple test in a row … On CI we need to restart the computer regularly to make sure the memory is freed. This is absolute non sense. The impossibility to free the memory by hand is a absolute nightmare. This problem seems to be reported to Microsoft for at least a decade as I found out on internet and as @wstaelens has here documented. Any news from the dev team ? |
@wstaelens as this issue doesn’t have a minimal repro, I was not able to validate from my end if this fix fixes this issue. But by the look of it, the issue seems to be the same. Could you please validate and let us know if it works. |
@hiteshwpfmsft hard to tell as this is 2 years old and happens in production. I guess when we will upgrade to .net 8/9 where these fixes will be added I hope it will be fixed. You may close this ticket and we will reopen/create a new one when we encounter it again in case it hasn't been fixed. @hiteshwpfmsft this is more important as the STA requirement is a showstopper : #4000 (comment) |
@wstaelens Understood; we’ll close this ticket for now. Feel free to reopen or create a new one if it reoccurs after your .NET 8/9 upgrade. Thanks for the update! |
originally posted at runtime but is for wpf: dotnet/runtime#66756
Description
Situation: we have a windows service running in .net 6 with an admin panel in asp.net core 6 (+ blazor + pri nt drivers etc...)
(complex solution, but for the memory leak mainly does this:)
When processing 5 documents, we see an increase of memory with ±1.5MB memory because
System.Windows.ContextLayoutManager+LayoutQueue+Request
and this is because of being called byXpsDocument.GetFixedDocumentSequence()
are never released or GC'd.Eventually when our service runs for a time, it just runs out of memory.
Reproduction Steps
unable to create a minimal repro-solution, our software should be run and configured to reproduce (if needed somebody can get in contact with me in PM).
I guess these code in stackoverflow topics will demonstrate a similar issue:
https://stackoverflow.com/questions/218681/opening-xps-document-in-net-causes-a-memory-leak
https://stackoverflow.com/questions/51463348/c-sharp-reading-xps-causing-memory-leak
https://stackoverflow.com/questions/12703796/creating-fixed-document-causes-memory-leak
https://social.msdn.microsoft.com/Forums/en-US/becc0d42-908a-435c-a4ff-175843b83ad8/memory-leak-while-opening-the-xps-document-in-documentviewer
https://social.msdn.microsoft.com/Forums/vstudio/en-US/b7fec24a-138b-4d3b-bdb3-cd4f0785e4ac/populating-collection-with-rendertargetbitmap-via-thread-causes-memory-leak
Expected behavior
Processing XPS documents should release memory.
Actual behavior
When processing XPS documents the memory increases, after processing 5.000 - 10.000 documents, our service crashes due to OutOfMemory. (depending on the hardware and type of documents this number can be higher/lower...)
Regression?
We've seen this issue in every version of .net core, seen it last in .net 5 and after upgrading to .net 6 it is still present.
This memory leak and the issues have been out there already for a while (also in .NET Framework).
see:
https://stackoverflow.com/questions/218681/opening-xps-document-in-net-causes-a-memory-leak
https://stackoverflow.com/questions/51463348/c-sharp-reading-xps-causing-memory-leak
https://stackoverflow.com/questions/12703796/creating-fixed-document-causes-memory-leak
https://social.msdn.microsoft.com/Forums/en-US/becc0d42-908a-435c-a4ff-175843b83ad8/memory-leak-while-opening-the-xps-document-in-documentviewer
https://social.msdn.microsoft.com/Forums/vstudio/en-US/b7fec24a-138b-4d3b-bdb3-cd4f0785e4ac/populating-collection-with-rendertargetbitmap-via-thread-causes-memory-leak
Known Workarounds
No working workaround for us... :sad
Configuration
VS 2019 Pro 16.11.11
VS 2022 17.2.0 Preview 2.0
Issue occurred in every version we've been using .net 5, .net 6
Windows 10 21H1
Windows 11 21H2
Other information
suggested fixes as preloading PresentationCore and/or PresentationFramework don't work (https://web.archive.org/web/20110404040352/http://support.microsoft.com/kb/942443)
Calling updatelayout as suggested in stackoverflow also doesn't seem to work:
https://stackoverflow.com/questions/218681/opening-xps-document-in-net-causes-a-memory-leak
https://stackoverflow.com/questions/51463348/c-sharp-reading-xps-causing-memory-leak
https://stackoverflow.com/questions/12703796/creating-fixed-document-causes-memory-leak
https://stackoverflow.com/questions/50560580/memory-leak-at-xpsdocument-getfixeddocumentsequence
https://social.msdn.microsoft.com/Forums/en-US/becc0d42-908a-435c-a4ff-175843b83ad8/memory-leak-while-opening-the-xps-document-in-documentviewer
https://social.msdn.microsoft.com/Forums/vstudio/en-US/b7fec24a-138b-4d3b-bdb3-cd4f0785e4ac/populating-collection-with-rendertargetbitmap-via-thread-causes-memory-leak
We really hope the team investigates some time in XPS as it is really terrible, and it always being updated to "Future", "Future", "Future" 😠 .
See also:
XPS huge memory issues #6296
XPS documents memory leak (System.Windows.ContextLayoutManager+LayoutQueue+Request and XpsDocument.GetFixedDocumentSequence()) runtime#66756
XPS documents from print driver are terribly slow runtime#51930
XPS documents in .NET Core can't be opened #3546
XPS documents in .NET Core can't be opened runtime#51929 (comment)
.NET 5 - Printing - XPS requires STA Threads #4000
[Question] [XPS] Drawing a Visual is always being rasterized #4466
Printing XPS files fails on Windows 8.1 #2106
Update XPS Serialization Stack for Packaging/Compression Semantic Changes #2085
Possible unmanaged memory leak when running code using Print API(DocumentPaginator) on Windows 10 #3754
The text was updated successfully, but these errors were encountered: