I've an OutOfmemory problem again.Our customers are asking more and more data to export to Excel.In the code below, the program is breaking during the loop or during the Save.At that moment the error message 'OutOfmemory' is appearing.
Is there a way to avoid this?Saving in between gives no solution. The memory stays increasing.Can I avoid somehow that I need to much memory?Also, I still need still to format some cells. This will also increase the request to memory.
I'm using : Infragistics3.excel.v10.2 (v.10.2.20102.1004)on a Windows XP with 2Gb of memory.
Here is the code : ------------------
Dim workbook As New Infragistics.Excel.Workbook(Infragistics.Excel.WorkbookFormat.Excel2007)Dim wks As Infragistics.Excel.Worksheet = NothingDim wksRow As Infragistics.Excel.WorksheetRowDim RowsCount As Integer = 0
workbook.SaveExternalLinkedValues = Falseworkbook.CalculationMode = Infragistics.Excel.CalculationMode.Manualworkbook.RecalculateBeforeSave = True
wks = workbook.Worksheets.Add("Sheet0")
With wks For rowi As Long = 1 To 150000
RowsCount += 1 wksRow = wks.Rows(rowi) With wksRow For i As Integer = 1 To 350 .Cells(i).Value = "VALUE" & i & "-" & rowi Next End With wksRow = Nothing NextEnd Withwks = Nothing
workbook.Save("c:\ABC11.xlsx")
Hello,
After we look at this issue more deeply with our development team and debug the sample I have created for this scenario based on your code and details we found that this error is caused by the fact that the sample is allocating unique strings to cells in 150,000 rows and 350 columns in each row. Each string is about 38 bytes. That is 52,500,000 unique strings with 38 bytes each, or 1,995,000,000 bytes, or almost 2GB of memory which are only needed for string values. Also in addition, it creates 52,500,000 WorksheetCell instances, which are 24 bytes each. This accounts for 1.25GB of memory. And generally this is too much memory being used only for the strings data. So in this particular example the most of the memory is used for the real data and there is no way to be optimized if the memory of the computer is limited. This is more seen especially on XP machines.
Let me know if you have any further questions.
Sincerely,DimiDeveloper Support EngineerInfragistics, Inc.