System.OutOfMemoryException while Creating PDF files

A

Aryan

Hi,

I am using C# with framework 2.0 and creating PDF files on-fly, along
with this I am using Windows 2003 Server.

I am using Byte[] to take the data input and then save into pdf format
on harddrive location.

Now after creating few successful pdf files, I am getting
"System.OutOfMemoryException".

Is this problem coming because of large data is been sent to Byte[] to
create PDF file or something else could be the cause.

If so, then how to resolve this issue??

Thanks in Advance,

Manoj
 
M

Miha Markic

Hi Aryan,

It might be that you aren't releasing the memory.
I suggest you to take a look at your application with a memory profiler.
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,


--
Ignacio Machin
http://www.laceupsolutions.com
Mobile & warehouse Solutions.
Aryan said:
Hi,

I am using C# with framework 2.0 and creating PDF files on-fly, along
with this I am using Windows 2003 Server.

What are you using to create the PDF? iTextSharp?
I am using Byte[] to take the data input and then save into pdf format
on harddrive location.

How big your PDFs are?
Now after creating few successful pdf files, I am getting
"System.OutOfMemoryException".

What if you use a file instead?

If this do not solve your question, post some code.
 
M

Marc Gravell

see cross-post to dotnet.general it is a 3000-5000 page report
generated in a single buffer via ReportExecutionService.

I can't think of anything I could possibly do here other than take it
back to first principles... my first question would be "why....?"

Marc
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,


--
Ignacio Machin
http://www.laceupsolutions.com
Mobile & warehouse Solutions.
Marc Gravell said:
see cross-post to dotnet.general it is a 3000-5000 page report generated
in a single buffer via ReportExecutionService.

I can't think of anything I could possibly do here other than take it back
to first principles... my first question would be "why....?"


Apparentely Render cannot use a Stream. It needs all the file in memoky,
hikes!
 
O

Oscar Bowyer

Manoj,

This sounds like a problem with something (probably the byte[]) not
being freed. Make sure your variables are going out of scope.

A couple of other ideas/possibilities.
1) GC is slow to to cleanup. (Very unlikely but might be possible.)
2) I believe System.Diagnostics namespace or GC has a way to check
current memory allocation. Stop the code after a couple of pdf files are
created and check memory allocation. If the allocation does not drop,
then you've got variables not being freed.
3) Check to file handle used to create the file. If not flushed and
closed, this could easily cause excess memory usage.

Hope this helps,
Oscar
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top