NPOI System Out Of Memory exception
I'm using NPOI as nugget package to generate xslx files.
In local eveything works fine and I never get OutOfMemory exception but on my azure application deployed I do make some OutOfMemory exception while writing my workbook to my ByteArrayOutputStream.
ByteArrayOutputStream bos = new ByteArrayOutputStream();
try
{
workbook.Write(bos);
}
catch (Exception ex)
{
_logger.LogError($"Impossible de convertir notre excel en byte[] : {ex.Message} \r\n{ex.StackTrace}");
throw;
}
finally {
bos.Close();
}
Here is how i'm copying my workbook to a file which is generating the System OutOfMemory exception that doesn't occurs locally.
My application is running on an Aure Webapp on 32 bit in Premium v2 P1V2 app service plan.
I'm using the same code to generate monthly report on an azure function which never make a System OutOfMemory even when generating excel that would make the error on the same time range on my web app. (Azure function are runing on a Premium v2 P2V2).
What should I do in order to not have my System Out Of memory on my web app ?