SharePoint error: Exception of type System.OutOfMemoryException was thrown

Last post 05-16-2008 3:30 PM by appdev. 18 replies.
Page 1 of 2 (19 items) 1 2 Next >
Sort Posts: Previous Next
  • 02-05-2008 12:18 PM

    • appdev
    • Top 75 Contributor
    • Joined on 01-10-2008
    • Wannabe Slacker
    • Points 118

    SharePoint error: Exception of type System.OutOfMemoryException was thrown

    We have an application, which consists of a set of controls written in C#, used to manage documents in SharePoint Portal Server 2003.  Our users are reporting that they encounter problems uploading documents using our interface.  This is the error they get while trying to upload documents.  Note: The document is uploaded into SharePoint using the SharePoint API.

    System.OutOfMemoryException: Exception of type System.OutOfMemoryException was thrown.

    In addition, they are sporadically get the following error:

    InnerException: System.Threading.ThreadAbortException: Thread was being aborted.
    at Microsoft.SharePoint.SPWeb.a(String A_0, Object[,]& A_1, Object[,]& A_2, UInt32& A_3, UInt32& A_4)
    at Microsoft.SharePoint.SPFolder.b()
    at Microsoft.SharePoint.SPFolder.get_Files()
    at SCDOT.Web.SharePoint.Utilities.UploadFile(String webSpace, String libraryPath, String fileName, Byte[ fileData)
    at SCDOT.Web.SharePoint.Utilities.UploadFile(String webSpace, String libraryPath, String fileName, String filePath)
    at SCDOT.EDMS.SharePoint.Controls.Interface.Base.Upload.Submit_Upload_Click(Object sender, EventArgs e)

    Does anyone have any ideas or suggestions as to what could be causing the problem here?

    Thanks in advance.

  •  Advertisement

    Featured Advertisement

     
  • 02-06-2008 1:40 AM In reply to

    • mosessaur
    • Top 25 Contributor
    • Joined on 09-21-2006
    • Cairo, Egypt
    • Wannabe Slacker
    • Points 725

    Re: SharePoint error: Exception of type System.OutOfMemoryException was thrown

    Could you please post a code snippet of your API usage?! It seems you are consuming memory in something or the files that is being uploaded are too large. 

    Muhammad M. Mosa Soliman
    Software Engineer
  • 02-06-2008 9:34 PM In reply to

    • appdev
    • Top 75 Contributor
    • Joined on 01-10-2008
    • Wannabe Slacker
    • Points 118

    Re: SharePoint error: Exception of type System.OutOfMemoryException was thrown

    Below is a snippet of the code used to upload the file to SharePoint:

    Microsoft.SharePoint.SPSite site = SPControl.GetContextSite(System.Web.HttpContext.Current);
    SPWeb web = site.AllWebs[webSpaceName];
    SPFolder folder = web.GetFolder(libraryName);

    folder.Files.Add(path, data, true);

    Thanks.

     

  • 02-07-2008 2:37 PM In reply to

    • mosessaur
    • Top 25 Contributor
    • Joined on 09-21-2006
    • Cairo, Egypt
    • Wannabe Slacker
    • Points 725

    Re: SharePoint error: Exception of type System.OutOfMemoryException was thrown

    Do your users encounter this issue everytime they try to upload document event after restarting the SPS application? or after sometimes of uploading operations they encounter this?!

    Are you closing and disposing the SPSite and SPWeb instances after finishing working with them?

    What I think is that these things are the reasons of your OutOfMemoryException.

     

    Muhammad M. Mosa Soliman
    Software Engineer
  • 02-07-2008 3:36 PM In reply to

    • appdev
    • Top 75 Contributor
    • Joined on 01-10-2008
    • Wannabe Slacker
    • Points 118

    Re: SharePoint error: Exception of type System.OutOfMemoryException was thrown

    The problem seems to be sporadic.  I have been told by the users that the error seems to occur after they have uploaded 4-5 documents but that number is not consistent.  The size of the files tend to range from 100-300KB in size.  They are all PDF documents.  When this error was reported I had to do a code review of my review and found out the SPSite and SPWeb instances weren't being disposed of so I added this code after the folder.Files.Add(path, data, true) statement.

       if (web != null)
       {
        web.Close();
        web.Dispose();
       }
       if (site != null)
       {
        site.Close();
        site.Dispose();
       }

    However, adding this code did not correct the problem.  The method responsible for uploading the files is contained inside a helper class.

  • 02-08-2008 6:27 AM In reply to

    • mosessaur
    • Top 25 Contributor
    • Joined on 09-21-2006
    • Cairo, Egypt
    • Wannabe Slacker
    • Points 725

    Re: SharePoint error: Exception of type System.OutOfMemoryException was thrown

     Well, did you restrarted you application after adding this code? did you redeploy it?

    I cannot see anything wrong but the disposing issue 

    Muhammad M. Mosa Soliman
    Software Engineer
  • 02-08-2008 8:53 AM In reply to

    • appdev
    • Top 75 Contributor
    • Joined on 01-10-2008
    • Wannabe Slacker
    • Points 118

    Re: SharePoint error: Exception of type System.OutOfMemoryException was thrown

    I executed an iisreset on the server once the assembly was redeployed after making this change.  The users still receive the error.

  • 02-08-2008 12:31 PM In reply to

    • mosessaur
    • Top 25 Contributor
    • Joined on 09-21-2006
    • Cairo, Egypt
    • Wannabe Slacker
    • Points 725

    Re: SharePoint error: Exception of type System.OutOfMemoryException was thrown

    Ok, are you able to test your code on some test environment that is similar to the production one?

    You need to do so, and if you encounter the issue on your test environment I recomment that you omit/comment the part of your code that is uploading your document to SharePoint, that would make the method do nothing actually. but you'll start to focus on why exactly this issue is happening. you need to troubleshoot on some test environment

    Muhammad M. Mosa Soliman
    Software Engineer
  • 02-08-2008 4:28 PM In reply to

    • appdev
    • Top 75 Contributor
    • Joined on 01-10-2008
    • Wannabe Slacker
    • Points 118

    Re: SharePoint error: Exception of type System.OutOfMemoryException was thrown

    We do have a test environment I could try this on.  It's not a carbon of the production environment but it's pretty close.  I'll run a few tests in the test environment to see if I can reproduce the error.  I'll let you know how this goes.  Thanks again.

  • 02-11-2008 11:54 AM In reply to

    • appdev
    • Top 75 Contributor
    • Joined on 01-10-2008
    • Wannabe Slacker
    • Points 118

    Re: SharePoint error: Exception of type System.OutOfMemoryException was thrown

    I've been unable to reproduce this error in our test environment so far this morning.  I've uploaded several documents into the system without any such error.  I'll keep trying and let you know what happens.

  • 02-12-2008 7:43 AM In reply to

    • mosessaur
    • Top 25 Contributor
    • Joined on 09-21-2006
    • Cairo, Egypt
    • Wannabe Slacker
    • Points 725

    Re: SharePoint error: Exception of type System.OutOfMemoryException was thrown

    maybe because in production there are many users who are trying to do that at the same time?! 

    Muhammad M. Mosa Soliman
    Software Engineer
  • 02-13-2008 4:04 PM In reply to

    • appdev
    • Top 75 Contributor
    • Joined on 01-10-2008
    • Wannabe Slacker
    • Points 118

    Re: SharePoint error: Exception of type System.OutOfMemoryException was thrown

    At maximum, there are only two users uploading documents at the very same time on this system.

  • 02-15-2008 3:39 PM In reply to

    • appdev
    • Top 75 Contributor
    • Joined on 01-10-2008
    • Wannabe Slacker
    • Points 118

    Re: SharePoint error: Exception of type System.OutOfMemoryException was thrown

    Do you think it would be in my best interest to have this class implement the IDisposable interface?  Doing so would allow me to dispose of the resources used by the class.  What do you think?  How would this affect the static methods within this class?  Even the UploadFile method is declared as static.

  • 04-29-2008 9:26 AM In reply to

    • nuclear
    • Top 500 Contributor
    • Joined on 04-29-2008
    • Wannabe Slacker
    • Points 21

    Re: SharePoint error: Exception of type System.OutOfMemoryException was thrown

    Hi

     I have a similar problem see my thread on http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=3253419&SiteID=1

     We have been struggling with this issue on Development and Testing environments, and tried everything. We even took out the document add to the library did that manually and just update the listitem of the document and still get the exceptions...

     Any ideas? because we are stuck!

  • 04-30-2008 11:13 AM In reply to

    • appdev
    • Top 75 Contributor
    • Joined on 01-10-2008
    • Wannabe Slacker
    • Points 118

    Re: SharePoint error: Exception of type System.OutOfMemoryException was thrown

    In our situation, it appeared to be an operating system issue.  The systems administrators discovered the server had Windows Server 2003 SP1 installed and not SP2 so he proceeded to upgrade the service pack.  Once the service pack was upgraded, we haven't received the OutOfMemoryException error since.  I wanted to wait long enough until I was satisfied the service pack actually corrected the issue at hand.  At this point, I guess it is safe to say the service pack corrected our problem.  Are you running Windows Server 2003?  If so, what service pack are you running?

    John Richardson, MCP, A+
    Applications Analyst
    S. C. Department of Transportation

Page 1 of 2 (19 items) 1 2 Next >