OutOfMemory exception

OutOfMemory exception

Forum member · Jun 10, 2010
I am using your example: http://www.DynamicPDF.com/Products/DynamicPDFForNET/Generator/Examples.csp#TableReport to generate a report from the MSSQL table. I have trouble with large amount of data - Out Of Memory exception. I see that your component is trying to load to memory the whole table, and when amount of used memory exceeds ~1Gb - then the application is crashed with subj. exception. Does your component, have a possibility to flush data from memory to HDD file, and do not keep everything into memory?

Re: OutOfMemory exception

Support · Jun 10, 2010
When building a large PDF document it will be required that the machine have enough memory to handle the entire content of the document in memory while it is being created. There is not a good way to "flush" the content out as the document is being created. We do not place any upper limit on the size of the PDF that can or can't be created, rather this will always just depend on the memory resources that the machine has. Please let us know if you have any other questions. Thanks, ceTe Software Support Team

Re: OutOfMemory exception

Forum member · Jun 11, 2010
The server have enough memory. I see that the process never have size more than ~1GB into memory. I think that the error occurs, because of other reasons, for example you are trying to load all into StringBuilder(that is just an example!) but StringBuilder can't keep more than ~1Gb in the memory(actually 2Gb, but in fact a bit more than one). Or you reserve memory in a manner current size * 2 after each adding of the new element. Please watch the stack trace below, may be it could help you? at ceTe.DynamicPDF.Text.LatinLineBreaker.GetLines(Char[] text, Int32 start, Int32 length, Single width, Single height, Font font, Single fontSize) at ceTe.DynamicPDF.Text.LineBreaker.GetLines(Char[] text, Single width, Font font, Single fontSize) at ceTe.DynamicPDF.PageElements.Cell..ctor(Row A_0, String A_1, Font A_2, Single A_3, Color A_4, Color A_5, Int32 A_6, Int32 A_7) at ceTe.DynamicPDF.PageElements.CellList.Add(String text, Font font, Single size, Color textColor, Color backColor, Int32 colSpan, Int32 rowSpan) at ceTe.DynamicPDF.PageElements.CellList.Add(String text) We have your license, and that exception give us troubles, can you help? At least, please answer the question: can we generate PDF without loading everything to RAM?

Re: OutOfMemory exception

Support · Jun 11, 2010
So is this the stacktrace for the "Out of Memory Exception" you are getting? The answer to your actual question is no. All the contents of the PDF that you are creating are in memory until the document is full put together and drawn to disk using our Draw method. Thanks, ceTe Software Support Team