Free Support Forum - groupdocs.com

Exception of type 'System.OutOfMemoryException' was thrown


#1

Hi,

I am trying to load PDF in viewer and everything seems working fine but after using web interface a few time i start getting follow error


Server Error in ‘/’ Application.

        <h2> <i>Exception of type 'System.OutOfMemoryException' was thrown.</i> </h2></span>

        <font face="Arial, Helvetica, Geneva, SunSans-Regular, sans-serif ">

        <b> Description: </b>An unhandled exception occurred during 

the execution of the current web request. Please review the stack trace
for more information about the error and where it originated in the
code.

        <br><br>

        <b> Exception Details: </b>System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.<br><br>

        <b>Source Error:</b> <br><br>

        <table bgcolor="#ffffcc" width="100%">
           <tbody><tr>
              <td>
                  <code>

An unhandled exception was generated during the execution of the current
web request. Information regarding the origin and location of the
exception can be identified using the exception stack trace below.

              </td>
           </tr>
        </tbody></table>

        <br>

        <b>Stack Trace:</b> <br><br>

        <table bgcolor="#ffffcc" width="100%">
           <tbody><tr>
              <td>
                  <code><pre>[OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.]

Groupdocs.Web.UI.Handlers.BaseHandler.OnException(Exception exception, HttpContext context) +194
Groupdocs.Web.UI.Handlers.ViewDocumentHandler.ProcessRequest(HttpContext context) +4001
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +341
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +69

              </td>
           </tr>
        </tbody></table>

        <br>

        <hr color="silver" size="1" width="100%">

        <b>Version Information:</b> Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.18446

        <br><br><br><font face="Arial, Helvetica, Geneva, SunSans-Regular, sans-serif ">Here is my code<br><br><font face="Arial, Helvetica, Geneva, SunSans-Regular, sans-serif ">    <div><br>        <div id="viewAREA" style="width: 1200px; height: 800px; position: relative;margin-bottom: 20px;"></div><br>        <%=Viewer.ClientCode()<br>            .TargetElementSelector("#viewAREA")<br>            .FilePath(this.Filename)<br>            .OpenThumbnails(false)<br>            .ShowThumbnails(true)<br>            .PreloadPagesCount(2)<br>            .ZoomToFitWidth()<br>    %><br>    </div><br><br><font face="Arial, Helvetica, Geneva, SunSans-Regular, sans-serif "><font face="Arial, Helvetica, Geneva, SunSans-Regular, sans-serif "><font face="Arial, Helvetica, Geneva, SunSans-Regular, sans-serif ">PDF </font></font>Fil<font face="Arial, Helvetica, Geneva, SunSans-Regular, sans-serif ">e si<font face="Arial, Helvetica, Geneva, SunSans-Regular, sans-serif ">ze is<b> 2</b><font face="Arial, Helvetica, Geneva, SunSans-Regular, sans-serif "><b>3</b><font face="Arial, Helvetica, Geneva, SunSans-Regular, sans-serif "><b>MB</b>.<br><br><font face="Arial, Helvetica, Geneva, SunSans-Regular, sans-serif "><font face="Arial, Helvetica, Geneva, SunSans-Regular, sans-serif "><font face="Arial, Helvetica, Geneva, SunSans-Regular, sans-serif ">Is there any <font face="Arial, Helvetica, Geneva, SunSans-Regular, sans-serif "><font face="Arial, Helvetica, Geneva, SunSans-Regular, sans-serif ">setting</font> which is forcing my system to getting out of memory?<br><font face="Arial, Helvetica, Geneva, SunSans-Regular, sans-serif ">BTW <font face="Arial, Helvetica, Geneva, SunSans-Regular, sans-serif ">i have 32GB ram in my development <font face="Arial, Helvetica, Geneva, SunSans-Regular, sans-serif ">pc with only 20GB in use, so it is not like i am using 99% of ram.</font></font></font><br></font></font></font></font><font face="Arial, Helvetica, Geneva, SunSans-Regular, sans-serif "></font></font></font></font></font></font></font></font></font>

#2

Hello,


We are sorry to hear that you have such issue. When you’re developing and debugging an application, you will typically run with the debug attribute in the web.config file set to true and your DLLs compiled in debug mode. However, before you deploy your application to test or to production, you should compile your components in release mode and set the debug attribute to false.

ASP.NET works differently on many levels when running in debug mode. In fact, when you are running in debug mode, the GC will allow your objects to remain alive longer (until the end of the scope) so you will always see higher memory usage when running in debug mode.

Another often unrealized side-effect of running in debug mode is that client scripts served via the webresource.axd and scriptresource.axd handlers will not be cached. That means that each client request will have to download any scripts (such as ASP.NET AJAX scripts) instead of taking advantage of client-side caching. This can lead to a substantial performance hit.


Since all these and the fact that you use a very big file for view you should try to do next: stop the VS and clean the cache, clean the project (it will remove temporary stored dll’s). Try to use .UseHtmlBasedEngine(true, true)


Also this error means that you reached of the memory limit that system gives for the server - not the total memory in the system.


Best regards.


#3

Thank you for quick reply.
I will compile in release and will use UseHtmlBasedEngine.


#4

Hello,


Thank you for the notification. If you will need more help please feel free to contact us.

Best regards.