1
Error Loading Big PDF Document
Problem reported by Nitin Sharma - 1/27/2020 at 1:02 AM
Not A Problem
Below error Occured while displaying 950 MB document, The file is stored in database as stream.

Exception of type 'System.OutOfMemoryException' was thrown

Please advise

12 Replies

Reply to Thread
0
Cem Alacayir Replied
Employee Post
First make sure you are using latest version Version 5.2.2 - January 24, 2020.

950 MB is a too big document.

> The file is stored in database as stream

How are you passing that stream to DocumentViewer? You should not use a MemoryStream, that will probably cause OutOfMemoryException. Just make sure you are disposing your streams and not storing huge files as bytes in memory. You can also use IDocumentHandler interface.

0
Nitin Sharma Replied
Please note that i am passing byte array to a document viewer , it load small documnets very well but when it 
comes to big files it gives System.OutOfMemoryException.

i understand that 950 mb is too big file but as per our business model we receive these kind of bigger files.

Ho can i download the latest version? 
0
Nitin Sharma Replied
Downloaded the latest version still same issue, please help
0
Cem Alacayir Replied
Employee Post
> Please note that i am passing byte array to a document viewer

So what can DocumentViewer do about it? You are already storing 950 MB bytes in memory before even passing it to DocumentViewer. So maybe you are getting  System.OutOfMemoryException even before your code enters DocumentViewer.

Solutions:
  • Increase your RAM
  • Use 64-bit process so more memory is available for .NET (IIS Express runs by default in 32-bit but VS setting can be turned on to run in 64-bit)
  • Save your big byte arrays to disk as temporary file and then pass the temporary file to DocumentViewer
  • Try to get a stream from your database instead of a byte array.

0
Nitin Sharma Replied
No, Its the document viewer which is giving error,

i tried to pass document directly from local disk without using any byte array or stream and it was still giving out of memory exception
0
Nitin Sharma Replied
Please note that big file form local disk is also not loading.

It does mean that document viewer has a file size limit , please can you let us know at least what is the maximum size of file supported by document viewer?

it would be great if you can update document viewer to handle such a large files.

Thank you

0
Cem Alacayir Replied
Employee Post
Once you create a 950 MB byte array, it stays in memory until GC (Garbage Collector) triggers and collects the unused byte array (frees the memory). So even if you write it to a temporary file later, 950 MB of your memory is still filled.

You can try this:

//Your byte array should not have any other reference and only reference should be set to null
yourByteArray = null;

//Then trigger GC manually to free up memory
GC.Collect();
Hopefully if GC frees up memory, then probably conversion would succeed.
0
Nitin Sharma Replied
Please note that below approach is also having issues with big files
 
so its not all about disposing the byte array and freeing up GC.

Anyways , Thank you for your kind responses.
0
Cem Alacayir Replied
Employee Post
Let me know if running under 64-bit process makes a difference (IIS by default runs in 64-bit mode, IIS Express by default runs in 32-bit mode).
0
Nivas Haneefa Replied
Thanks Cem for your kind  responses.
I work with Nitin in this project.
It is already running in 64-bit process.
please let us know how to fix this issue . Thanks in advance


0
Aastha Desai Replied
Hello,
I am using the below approach for document viewer(version 5.9.7)
filepath = this.Server.MapPath("Any path");
documentViewer.Document = filepath;
Which is causing the System.OutOfMemoryException.


please let us know how to fix this issue. Thanks in advance


0
Cem Alacayir Replied
Employee Post
Always test your problem files with our live demo because it uses the latest version (currently v6.0) so it's possible that your problem is already fixed with the latest version:

Don't worry, your uploaded files are automatically deleted after your session expires (they are not public, only the uploader can see them).

Reply to Thread