Утечка памяти в XpsDocument.GetFixedDocumentSequence () - PullRequest
0 голосов
/ 28 мая 2018

Я получаю утечку памяти в строке кода ниже.

 var fixedSequence = xpsDoc.GetFixedDocumentSequence();
 if (fixedSequence == null) return;  

Я попробовал ниже приведенные решения. Добавление UpdateLayout не может решить проблему.

https://stackoverflow.com/a/7102886
https://stackoverflow.com/a/2410588

Я смотрю нижедва исключения из-за сбоя службы Windows:

  1. Недостаточно памяти (в XpsDocument.GetFixedDocumentSequence ())
  2. System.Windows.Markup.XamlParseException

Сведения об исключении для System.Windows.Markup.XamlParseException

Exception Info: System.ComponentModel.Win32Exception
   at MS.Win32.UnsafeNativeMethods.CreateWindowEx(Int32, System.String, System.String, Int32, Int32, Int32, Int32, Int32, System.Runtime.InteropServices.HandleRef, System.Runtime.InteropServices.HandleRef, System.Runtime.InteropServices.HandleRef, System.Object)
   at MS.Win32.HwndWrapper..ctor(Int32, Int32, Int32, Int32, Int32, Int32, Int32, System.String, IntPtr, MS.Win32.HwndWrapperHook[])
   at System.Windows.Media.MediaContextNotificationWindow..ctor(System.Windows.Media.MediaContext)
   at System.Windows.Media.MediaContext..ctor(System.Windows.Threading.Dispatcher)
   at System.Windows.Media.MediaContext.From(System.Windows.Threading.Dispatcher)
   at System.Windows.Media.Visual.VerifyAPIReadWrite()
   at System.Windows.Media.VisualCollection.Add(System.Windows.Media.Visual)
   at System.Windows.Controls.UIElementCollection.AddInternal(System.Windows.UIElement)
   at MS.Internal.Xaml.Runtime.ClrObjectRuntime.Add(System.Object, System.Xaml.XamlType, System.Object, System.Xaml.XamlType)

Exception Info: System.Windows.Markup.XamlParseException
   at System.Windows.Markup.XamlReader.RewrapException(System.Exception, System.Xaml.IXamlLineInfo, System.Uri)
   at System.Windows.Markup.WpfXamlLoader.Load(System.Xaml.XamlReader, System.Xaml.IXamlObjectWriterFactory, Boolean, System.Object, System.Xaml.XamlObjectWriterSettings, System.Uri)
   at System.Windows.Markup.WpfXamlLoader.Load(System.Xaml.XamlReader, Boolean, System.Uri)
   at System.Windows.Markup.XamlReader.Load(System.Xaml.XamlReader, System.Windows.Markup.ParserContext)
   at System.Windows.Markup.XamlReader.Load(System.Xml.XmlReader, System.Windows.Markup.ParserContext, System.Windows.Markup.XamlParseMode)
   at System.Windows.Markup.XamlReader.Load(System.IO.Stream, System.Windows.Markup.ParserContext)
   at System.Windows.Xps.Packaging.XpsDocument.GetFixedDocumentSequence()
   at Softdocs.Imaging.MultiPageStreamSplitter.<OpenXpsDocument>b__1()
   at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
   at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
   at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
   at System.Threading.ThreadHelper.ThreadStart()
...