Ticket Q458697
Visible to All Users

XtraReport 'out of memory' error

created 12 years ago

Hello,
First let me comment that I really like the XtraReporing Suite, it is great to work and I'm pleased with the results.
I'm almost done with a product and am doing some stress testng on the Xtrareports and have run into an 'out of memory' error when trying to load a larger number of images.
I have a basic detail report that gets data from SQLServer compact, shows some field data and also shows up to 6 small images for each detail row . This works great when unit testing wth smaller quantities of data, but when I try to create a report with 1500 rows, each with 4 images (2mb each) I get an 'out of memory' error. Note: The file name is stored in the database.
My computer is a little older, DELL Latitude w/ Intel Core2 Duo and only 2GB memory) but I would think it would just take longer to run and not error out. I am running the .exe with Visual Studio closed. Any thoughts or feedback would be appreciated. Perhaps my code could be better, please see my snipits below: I'm using DXExperience 12.1, the exact dll is: DevExpress.XtraReports.v12.1.dll
Public Class XtraReportInventory

Public Sub New()
' This call is required by the Windows Form Designer.
        InitializeComponent()
' Add any initialization after the InitializeComponent() call.
InventoryTableAdapter.Connection.ConnectionString = gsConnectionString
        InventoryTableAdapter.FillByHomeIdSortLocItemCatg(DataSetInventory1.Inventory, gsHomeId) 'pass dataset, parm (setup in dataset/table adapter query)

' Add any initialization after the InitializeComponent() call.
        XrPictureBox1.DataBindings.Add(New XRBinding("Tag", DataSource, "Pic1"))
        XrPictureBox2.DataBindings.Add(New XRBinding("Tag", DataSource, "Pic2"))
        XrPictureBox3.DataBindings.Add(New XRBinding("Tag", DataSource, "Pic3"))
        XrPictureBox4.DataBindings.Add(New XRBinding("Tag", DataSource, "Pic4"))
        XrPictureBox5.DataBindings.Add(New XRBinding("Tag", DataSource, "Pic5"))
        XrPictureBox6.DataBindings.Add(New XRBinding("Tag", DataSource, "Pic6"))
End Sub
Private Sub XrPictureBoxALL_BeforePrint(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintEventArgs) Handles XrPictureBox1.BeforePrint, XrPictureBox2.BeforePrint, XrPictureBox3.BeforePrint, XrPictureBox4.BeforePrint, XrPictureBox5.BeforePrint, XrPictureBox6.BeforePrint

Dim picture As XRPictureBox = CType(sender, XRPictureBox)
        If picture.Tag <> Nothing Then
            picture.Image = New Bitmap(Bitmap.FromFile(gsImagePath + "" + picture.Tag.ToString()))
'picture.Image = Image.FromFile(gsImagePath + "" + picture.Tag.ToString()) 'Note: This also gets out of memory error
        Else
            e.Cancel = True
        End If
End Sub
'Here is how the report is invoked
Dim xtraRpt As New XtraReportInventory
xtraRpt.ShowPreviewMarginLines = False
If gsReportEmptyDataset = False Then
   Me.Cursor = Cursors.WaitCursor
   xtraRpt.CreateDocument()
   xtraRpt.PrintingSystem.SetCommandVisibility(DevExpress.XtraPrinting.PrintingSystemCommand.Save, DevExpress.XtraPrinting.CommandVisibility.None)
   xtraRpt.PrintingSystem.SetCommandVisibility(DevExpress.XtraPrinting.PrintingSystemCommand.Open, DevExpress.XtraPrinting.CommandVisibility.None)
   xtraRpt.PrintingSystem.ShowMarginsWarning = False
   xtraRpt.PrintingSystem.ShowPrintStatusDialog = True
   Me.Cursor = Cursors.Default
   xtraRpt.ShowPreviewDialog()
Else
   InfoMsg.lblMsg.Text = GS_NO_REPORT_DATA
   InfoMsg.Show()
End If
xtraRpt.Dispose()
NOTE: DUMP PROVIDED BELOW:
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.
************** Exception Text **************
System.OutOfMemoryException: Out of memory.
   at System.Drawing.Graphics.CheckErrorStatus(Int32 status)
   at System.Drawing.Graphics.DrawImage(Image image, Int32 x, Int32 y, Int32 width, Int32 height)
   at System.Drawing.Bitmap…ctor(Image original, Int32 width, Int32 height)
   at System.Drawing.Bitmap…ctor(Image original)
   at HJOURNAL.XtraReportInventory.XrPictureBoxALL_BeforePrint(Object sender, PrintEventArgs e)
   at DevExpress.XtraReports.UI.XRControl.OnBeforePrint(PrintEventArgs e)
   at DevExpress.XtraReports.UI.XRControl.GetPrintableBrick(XRWriteInfo writeInfo)
   at DevExpress.XtraReports.UI.XRControl.GetPrintableBrick(XRWriteInfo writeInfo)
   at DevExpress.XtraReports.UI.XRControl.GetPrintableBrick(XRWriteInfo writeInfo)
   at DevExpress.XtraReports.UI.XRControl.GetPrintableBrick(XRWriteInfo writeInfo)
   at DevExpress.XtraReports.UI.XRControl.WriteContentTo(XRWriteInfo writeInfo)
   at DevExpress.XtraReports.UI.Band.GenerateContent(DocumentBand docBand, Int32 rowIndex, Boolean fireBeforePrint)
   at DevExpress.XtraReports.UI.Band.GenerateWithSubreports(DocumentBand docBand, Int32 rowIndex, Boolean fireBeforePrint, PageBuildInfo pageBuildInfo)
   at DevExpress.XtraReports.Native.SelfGeneratedDocumentBand…ctor(RootDocumentBand root, DocumentBandKind kind, Band band, Int32 rowIndex, Boolean fireBeforePrint, PageBuildInfo pageBuildInfo)
   at DevExpress.XtraReports.UI.Band.CreateDocumentBand(Int32 rowIndex, RootDocumentBand rootDocBand, PageBuildInfo pageBuildInfo)
   at DevExpress.XtraReports.UI.DetailBand.CreateDocumentBand(Int32 rowIndex, Int32 rowCount, RootDocumentBand rootDocBand, PageBuildInfo pageBuildInfo)
   at DevExpress.XtraReports.Native.Printing.DetailWriterBase.WriteDetailCore(PageBuildInfo pageBuildInfo)
   at DevExpress.XtraReports.Native.Printing.DetailWriterBase.Write(DocumentBand rootBand, PageBuildInfo pageBuildInfo)
   at DevExpress.XtraReports.Native.Printing.DocumentBuilder.GetBand(DocumentBand rootBand, PageBuildInfo pageBuildInfo)
   at DevExpress.XtraPrinting.Native.DocumentBand.GetBand(PageBuildInfo pageBuildInfo)
   at DevExpress.XtraPrinting.Native.PageHeaderFooterRowBuilderBase.CanProcessDetail(DocumentBand rootBand, PageBuildInfo pageBuildInfo)
   at DevExpress.XtraPrinting.Native.PageRowBuilderBase.FillPageForBands(DocumentBand rootBand, RectangleF bounds, ProcessBandsDelegate process)
   at DevExpress.XtraPrinting.Native.PageRowBuilderBase.FillReportDetails(DocumentBand rootBand, RectangleF bounds)
   at DevExpress.XtraPrinting.Native.PageRowBuilderBase.FillReportDetailsAndFooter(DocumentBand rootBand, RectangleF bounds)
   at DevExpress.XtraPrinting.Native.PageHeaderFooterRowBuilderBase.FillReportDetailsAndFooter(DocumentBand rootBand, RectangleF bounds)
   at DevExpress.XtraPrinting.Native.PageRowBuilderBase.FillPage(DocumentBand rootBand, RectangleF bounds)
   at DevExpress.XtraPrinting.Native.PageRowBuilderBase.FillPageRecursive(DocumentBand rootBand, DocumentBand docBand, RectangleF bounds)
   at DevExpress.XtraPrinting.Native.PageHeaderFooterRowBuilderBase.FillPageRecursive(DocumentBand rootBand, DocumentBand docBand, RectangleF bounds)
   at DevExpress.XtraPrinting.Native.PageRowBuilderBase.FillPageForBandCore(DocumentBand rootBand, RectangleF bounds, RectangleF newBounds)
   at DevExpress.XtraPrinting.Native.PageRowBuilderBase.FillPageForBands(DocumentBand rootBand, RectangleF bounds, ProcessBandsDelegate process)
   at DevExpress.XtraPrinting.Native.PageRowBuilderBase.FillReportDetails(DocumentBand rootBand, RectangleF bounds)
   at DevExpress.XtraPrinting.Native.PageRowBuilderBase.FillReportDetailsAndFooter(DocumentBand rootBand, RectangleF bounds)
   at DevExpress.XtraPrinting.Native.PageHeaderFooterRowBuilderBase.FillReportDetailsAndFooter(DocumentBand rootBand, RectangleF bounds)
   at DevExpress.XtraPrinting.Native.PageRowBuilderBase.FillPage(DocumentBand rootBand, RectangleF bounds)
   at DevExpress.XtraPrinting.Native.PageBuildEngine.Build()
   at DevExpress.XtraPrinting.Native.PageBuildEngine.BuildPages(DocumentBand rootBand)
   at DevExpress.XtraPrinting.Native.DocumentHelper.BuildPagesCore()
   at DevExpress.XtraPrinting.Native.DocumentHelper.BuildPages()
   at DevExpress.XtraPrinting.Native.PrintingDocument.BuildPages()
   at DevExpress.XtraPrinting.Native.PrintingDocument.End(Boolean buildPagesInBackground)
   at DevExpress.XtraPrinting.PrintingSystemBase.End(Boolean buildPagesInBackground)
   at DevExpress.XtraReports.UI.XtraReport.CreateDocumentCore2(PrintingSystemBase ps, Single progressRange, Boolean buildPagesInBackground)
   at DevExpress.XtraReports.UI.XtraReport.CreateDocumentCore(Single progressRange, Boolean buildPagesInBackground)
   at DevExpress.XtraReports.UI.XtraReport.CreateDocument(Single progressRange, Boolean buildPagesInBackground)
   at DevExpress.XtraReports.UI.XtraReport.CreateDocument(Boolean buildPagesInBackground)
   at DevExpress.XtraReports.UI.XtraReport.CreateDocument()
   at HJOURNAL.InvRpts.btnStdReports_Click(Object sender, EventArgs e)
   at System.Windows.Forms.Control.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ButtonBase.WndProc(Message& m)
   at System.Windows.Forms.Button.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

************** Loaded Assemblies **************
mscorlib
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.4234 (VistaSP2GDR.050727-4200)
    CodeBase: file:///C:/Windows/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
----------------------------------------
HJOURNAL3
    Assembly Version: 3.0.0.0
    Win32 Version: 3.0.0.0
    CodeBase: file:///C:/HJournal3.0Biz/HJOURNAL.NET/bin/HJOURNAL3.exe
----------------------------------------
Microsoft.VisualBasic
    Assembly Version: 8.0.0.0
    Win32 Version: 8.0.50727.4016 (NetFxQFE.050727-4000)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Microsoft.VisualBasic/8.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualBasic.dll
----------------------------------------
System
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.4235 (VistaSP2GDR.050727-4200)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Windows.Forms
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.4235 (VistaSP2GDR.050727-4200)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System.Drawing
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.4235 (VistaSP2GDR.050727-4200)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
System.Runtime.Remoting
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.4016 (NetFxQFE.050727-4000)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Runtime.Remoting/2.0.0.0__b77a5c561934e089/System.Runtime.Remoting.dll
----------------------------------------
System.Configuration
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.4016 (NetFxQFE.050727-4000)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Configuration/2.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
----------------------------------------
System.Xml
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.4016 (NetFxQFE.050727-4000)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Xml/2.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------
DevExpress.XtraSpellChecker.v12.1
    Assembly Version: 12.1.5.0
    Win32 Version: 12.1.5.0
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/DevExpress.XtraSpellChecker.v12.1/12.1.5.0__b88d1754d700e49a/DevExpress.XtraSpellChecker.v12.1.dll
----------------------------------------
DevExpress.XtraEditors.v12.1
    Assembly Version: 12.1.5.0
    Win32 Version: 12.1.5.0
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/DevExpress.XtraEditors.v12.1/12.1.5.0__b88d1754d700e49a/DevExpress.XtraEditors.v12.1.dll
----------------------------------------
DevExpress.Utils.v12.1
    Assembly Version: 12.1.5.0
    Win32 Version: 12.1.5.0
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/DevExpress.Utils.v12.1/12.1.5.0__b88d1754d700e49a/DevExpress.Utils.v12.1.dll
----------------------------------------
DevExpress.Data.v12.1
    Assembly Version: 12.1.5.0
    Win32 Version: 12.1.5.0
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/DevExpress.Data.v12.1/12.1.5.0__b88d1754d700e49a/DevExpress.Data.v12.1.dll
----------------------------------------
DevExpress.SpellChecker.v12.1.Core
    Assembly Version: 12.1.5.0
    Win32 Version: 12.1.5.0
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/DevExpress.SpellChecker.v12.1.Core/12.1.5.0__b88d1754d700e49a/DevExpress.SpellChecker.v12.1.Core.dll
----------------------------------------
Accessibility
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.4016 (NetFxQFE.050727-4000)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Accessibility/2.0.0.0__b03f5f7f11d50a3a/Accessibility.dll
----------------------------------------
DevExpress.XtraBars.v12.1
    Assembly Version: 12.1.5.0
    Win32 Version: 12.1.5.0
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/DevExpress.XtraBars.v12.1/12.1.5.0__b88d1754d700e49a/DevExpress.XtraBars.v12.1.dll
----------------------------------------
System.Data.SqlServerCe
    Assembly Version: 3.5.0.0
    Win32 Version: 3.5.5386.0
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Data.SqlServerCe/3.5.0.0__89845dcd8080cc91/System.Data.SqlServerCe.dll
----------------------------------------
System.Data
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.4016 (NetFxQFE.050727-4000)
    CodeBase: file:///C:/Windows/assembly/GAC_32/System.Data/2.0.0.0__b77a5c561934e089/System.Data.dll
----------------------------------------
System.Transactions
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.4016 (NetFxQFE.050727-4000)
    CodeBase: file:///C:/Windows/assembly/GAC_32/System.Transactions/2.0.0.0__b77a5c561934e089/System.Transactions.dll
----------------------------------------
System.EnterpriseServices
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.4016 (NetFxQFE.050727-4000)
    CodeBase: file:///C:/Windows/assembly/GAC_32/System.EnterpriseServices/2.0.0.0__b03f5f7f11d50a3a/System.EnterpriseServices.dll
----------------------------------------
DevExpress.XtraPrinting.v12.1
    Assembly Version: 12.1.5.0
    Win32 Version: 12.1.5.0
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/DevExpress.XtraPrinting.v12.1/12.1.5.0__b88d1754d700e49a/DevExpress.XtraPrinting.v12.1.dll
----------------------------------------
DevExpress.Printing.v12.1.Core
    Assembly Version: 12.1.5.0
    Win32 Version: 12.1.5.0
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/DevExpress.Printing.v12.1.Core/12.1.5.0__b88d1754d700e49a/DevExpress.Printing.v12.1.Core.dll
----------------------------------------
DevExpress.XtraReports.v12.1
    Assembly Version: 12.1.5.0
    Win32 Version: 12.1.5.0
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/DevExpress.XtraReports.v12.1/12.1.5.0__b88d1754d700e49a/DevExpress.XtraReports.v12.1.dll
----------------------------------------
System.Data.DataSetExtensions
    Assembly Version: 3.5.0.0
    Win32 Version: 3.5.30729.1 built by: SP
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Data.DataSetExtensions/3.5.0.0__b77a5c561934e089/System.Data.DataSetExtensions.dll
----------------------------------------
System.Core
    Assembly Version: 3.5.0.0
    Win32 Version: 3.5.30729.1 built by: SP
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Core/3.5.0.0__b77a5c561934e089/System.Core.dll
----------------------------------------
System.Web
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.4223 (VistaSP2GDR.050727-4200)
    CodeBase: file:///C:/Windows/assembly/GAC_32/System.Web/2.0.0.0__b03f5f7f11d50a3a/System.Web.dll
----------------------------------------
DevExpress.RichEdit.v12.1.Core
    Assembly Version: 12.1.5.0
    Win32 Version: 12.1.5.0
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/DevExpress.RichEdit.v12.1.Core/12.1.5.0__b88d1754d700e49a/DevExpress.RichEdit.v12.1.Core.dll
----------------------------------------
DevExpress.Office.v12.1.Core
    Assembly Version: 12.1.5.0
    Win32 Version: 12.1.5.0
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/DevExpress.Office.v12.1.Core/12.1.5.0__b88d1754d700e49a/DevExpress.Office.v12.1.Core.dll
----------------------------------------
************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.
For example:
<configuration>
    <system.windows.forms jitDebugging="true" />
</configuration>
When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.

Answers approved by DevExpress Support

created 12 years ago (modified 12 years ago)

Hi Fred,
Please note that the XtraReports Suite loads all images into the memory to generate a document. So, a report with 6000 images (1500x4) will use approximately 12GB (1500x4x(2MB for each image)). I suggest that you reduce volume data used in the report by filtering data at a data source's Level.
Thanks,
Elliot

    Comments (2)

      Elliot,
      Thanks for your reply however I'm a bit surprised at your suggestion. Last night I found a workable solution that does generate the reprot with the 6000 images without issue, even on my older machine. I planned to update this post but your reply came in first.
      After experimenting and hunting around other posts, I realized that you have another option on the xtrareports picturebox control: xrPicBox.ImageUrl It seems that if I just set the ImageUrl property = the path of the image on the hard drive the entire document generates fin and in a reasonable amount of time.
      Wouldn't this be the recommended solution ?? verses your suggestion to reduce the volume of data. Can you please comment further.
      Thanks for your help!

      DevExpress Support Team 12 years ago

        Yes, you are completely right. You can use the XRPictureBox.ImageUrl property to decrease application memory usage. Please note that it is necessary to use the Image property if you want an image to be saved within a report.

        Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

        Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.