Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EPPlus Large Dataset Issue with Out of Memory Exception

System Out of Memory Exception. I see the memory Stream is only flushed when saved. We have 1.5 - 2GB Datasets.

I am using EPPlus Version 3.1.3.0

We do the following in code.

We loop through

     --> Create a Package
        --> each table in the datareader
            -->   Add WorkSheet to the Package 
        --> Dispose Each table.
     --> Save the  Package.

Each Datatable is of a 300Mg Size up to 15 Tables out form the System.

This is causing a issue, I have logged this in detail @ https://epplus.codeplex.com/workitem/15085

I still want to be able to use EPPlus its very nice API. but is there a better way to free up a worksheet once we add it to the package.

Thank you for helping.

like image 291
bhushanvinay Avatar asked Nov 06 '14 19:11

bhushanvinay


People also ask

How to solve system OutOfMemoryException in c#?

You can do either of the following to address the error: Replace the call to the StringBuilder. StringBuilder(Int32, Int32) constructor with a call any other StringBuilder constructor overload. The maximum capacity of your StringBuilder object will be set to its default value, which is Int32.

How do you avoid Outofmemoryexception?

To avoid this exception while working with StringBuilder, we can call the constructor StringBuilder. StringBuilder(Int32, Int32) and can set the MaxCapacity property to a value that will be large enough to serve the accommodation required when we expand the corresponding StringBuilder object.

Does EPPlus work with XLS?

Does EPPlus support XLS? EPPlus does not work with the XLS format.

What is EPPlus DLL?

EPPlus is a very helpful open-source 3rd party DLL for writing data to excel. EPPlus supports multiple properties of spreadsheets like cell ranges, cell styling, charts, pictures, shapes, comments, tables, protection, encryption, pivot tables, data validation, conditional formatting, formula calculation, etc.


1 Answers

I had this problem, but I fixed it by switching the option of "Platform target", from x86 to x64 or "Any CPU". ( right click on the project, then select "Properties", then the tab "Build", then on "Platform target" select "x64" )

The problem is that for platform x86 you can use only about 1.8 GB of RAM. For platform x64, you do not have this limitation.

like image 144
Grigore Cosmin Magerusan Avatar answered Sep 18 '22 14:09

Grigore Cosmin Magerusan