473,385 Members | 1,944 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

System.OutOfMemoryException while Creating PDF files

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

Oct 23 '07 #1
2 3590
A lot of factors could be in play here. Trying to use enormous arrays
is a big contender. Accidentally holding on to large arrays (directly
or indirectly) will compound this.

Where possibly, the most memory-efficiet way to deal with large binary
data is using a streamed approach - whether that means to/from a
file/database/network etc depends on the scenario. But it means only
having to handle a small buffer of working data.

Can you give any more information on your setup? Size of byte[]? Any
chance you are keeping old instances alive? (perhaps subscribing to
long-lived events, such as static events). Would streaming be an
option, etc.

Marc
Oct 23 '07 #2
On 23 Oct, 15:19, "Marc Gravell" <marc.grav...@gmail.comwrote:
A lot of factors could be in play here. Trying to use enormous arrays
is a big contender. Accidentally holding on to large arrays (directly
or indirectly) will compound this.

Where possibly, the most memory-efficiet way to deal with large binary
data is using a streamed approach - whether that means to/from a
file/database/network etc depends on the scenario. But it means only
having to handle a small buffer of working data.

Can you give any more information on your setup? Size of byte[]? Any
chance you are keeping old instances alive? (perhaps subscribing to
long-lived events, such as static events). Would streaming be an
option, etc.

Marc
Mark, Thanks for prompt reply.

Here is the sample code snippet.

I am using SQLReport Server 2005 to get the data.

Byte[] results;
ReportExecutionService rsExec;
results = rsExec.Render(format, deviceInfo,
out extension, out encode,
out mimeType, out warnings, out streamIDs);

SavePDF(results, filename); // calling SavePDF method to save the
result array output in PDF form.

private bool SavePDF(Byte[] results, string fileName)
{
try
{

using (FileStream stream = File.OpenWrite(fileName))
{
stream.Write(results, 0, results.Length);
stream.Close();
stream.Dispose();
}

return true;
}
catch(Exception ex)
{
throw;
}
}
Now,
1If I get large stream from ReportExecutionService then how to split
it in chunks and create a pdf file(say pdf has something around 3000 /
5000 pages in it)

Thanks in Advance.
Manoj

Oct 23 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: solomon | last post by:
Hi, I have installed VS.Net(Ver:7.0.9466) & .Net_Frameword_1.0 (Ver: 1.0.3705). Until recently, I could develop and run applications using the IDE. A couple of days ago, I downloaded a sample...
1
by: king solomon | last post by:
Hi, I have installed VS.Net(Ver:7.0.9466) & .Net_Frameword_1.0 (Ver: 1.0.3705). Until recently, I could develop and run applications using the VS.IDE. A couple of days ago, I downloaded a...
0
by: Per Bergland | last post by:
After many woes, I finally managed to get a stack dump of my System Service (written in C#) that insists on crashing when launched at system boot time (see below on how to get this dump - I...
1
by: Ripul Handa | last post by:
Hi We are running IIS 5.0 cluster with cisco local director. We are running a website on 2 webservers and I have been observing that from past few days we have are getting this error message of...
1
by: SMG - Idealake | last post by:
Hi all, I am getting following error on my error, what could be the reason? Exception of type System.OutOfMemoryException was thrown. Description: An unhandled exception occurred during the...
1
by: Ashkan Daie | last post by:
Hi All, When trying to install a performance counter via InstallUtil I get the following exception: Creating performance counter category Enterprise Library Caching. An exception occurred...
5
by: jwgoerlich | last post by:
Hello, I need to create a 1 GB Byte array in memory. I can create it on a Win2000 system. On a Win2003 system, the application throws a System.OutOfMemoryException error. Both are running the...
0
by: AY | last post by:
Hello, We use a third party reporting system (Actuate) which provides soap services via WSDL. My web application was initially built in Visual Studio 2003 using .NET 1.1. I was able to...
8
by: =?Utf-8?B?UGlnZ3k=?= | last post by:
Hi to all, I am getting this System.OutOfMemoryException calling the Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(<stream>,<Obj>) method. The type of <streamis...
5
by: Aryan | last post by:
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.