1642930 - Out Of Memory Exception when using the Crystal Reports WPF viewer in a VS1020 application

SAP Knowledge Base Article - Public

1642930 - Out Of Memory Exception when using the Crystal Reports WPF viewer in a VS1020 application

Symptom

  • A columnar report retrieving images from a database
  • The processing of the report is very slow
  • Often the application terminates with the error;

OutOfMemoryException was unhandled

''

  • Partial details of error:

System.OutOfMemoryException was unhandled
  Message=Insufficient memory to continue the execution of the program.
  Source=PresentationCore
  StackTrace:
       at System.Windows.Media.Imaging.CachedBitmap.InitFromMemoryPtr(Int32 pixelWidth, Int32 pixelHeight, Double dpiX, Double dpiY, PixelFormat pixelFormat, BitmapPalette palette, IntPtr buffer, Int32 bufferSize, Int32 stride)
       at SAPBusinessObjects.WPF.ViewerShared.WPFUtils.DrawGDIBitmap(DrawingContext context, Bitmap bitmap, Rect rect)
       at SAPBusinessObjects.WPF.ViewerShared.PageRender.drawImageInstance(ImageObjectInstance imageObjectInstance, VisualCollection visuals)
       at SAPBusinessObjects.WPF.ViewerShared.PageRender.drawReportObjectInstance(ReportObjectInstance instance, VisualCollection visuals, Rect sectionClipRect)
       at SAPBusinessObjects.WPF.ViewerShared.PageRender.drawSectionInstance(SectionInstance section, VisualCollection visuals)
       at SAPBusinessObjects.WPF.ViewerShared.PageRender.drawSubreportObjectInstance(SubreportObjectInstance subreportObjectInstance, VisualCollection visuals)
       at SAPBusinessObjects.WPF.ViewerShared.PageRender.drawReportObjectInstance(ReportObjectInstance instance, VisualCollection visuals, Rect sectionClipRect)
       at SAPBusinessObjects.WPF.ViewerShared.PageRender.drawSectionInstance(SectionInstance section, VisualCollection visuals)
       at SAPBusinessObjects.WPF.ViewerShared.PageRender.Render(VisualCollection visuals)
       at SAPBusinessObjects.WPF.ViewerShared.PageView.Render()
       at SAPBusinessObjects.WPF.ViewerShared.PageView.set_PageObj(PageObject value)
       at SAPBusinessObjects.WPF.Viewer.DocumentView.ShowNthPage(Int32 PageNumber, Boolean hasAnimation)
       at SAPBusinessObjects.WPF.Viewer.ReportAlbum.OnCreateNewDocumentViewComplete(CreateNewDocumentArgs args)
       at SAPBusinessObjects.WPF.Viewer.DelegateMarshaler.<>c__DisplayClass6`1.<Invoke>b__4(Object )
       .
       .
       .
       .

Environment

  • Crystal Reports for Visual Studio 2010
  • VS2010

Cause

  • The image size was over 5MG
  • Image in the database was 4288 x 3216 pixels, yet in the report the size of the image was 360 x 370 pixels (about 15% of the actual size)
  • This is too large for the CR image engine to process

Resolution

  • Reduce the image to the actual size it will have in the report
  • This step resulted in an image of  215 KB which allowed the application to work without errors

Keywords

CR2010 2010 CR4VS2010 CR4VS VS2010 NET2010 Crystal Reports for .NET Framework 4.0 crforvs 13 crash terminates System.OutOfMemoryException   , KBA , BI-DEV-NET-SDK , .NET SDK / COM SDK , Problem

Product

SAP Crystal Reports, developer version for Microsoft Visual Studio