Windows Service, getting outOf memory exception

csharp , db Sweden
  • 12 years ago

    Hello,

     I'm managing an application that is using a Windows Service to handle request from application to the database. We have problems with OutOfMemory exception when trying to run bigger loads of data an also when trying to write bigger amount of data to files.

    This is the error message we get. 

    Error while delivering batch: System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown. at System.String.GetStringForStringBuilder(String value, Int32 startIndex, Int32 length, Int32 capacity) at System.Text.StringBuilder.GetNewString(String currentString, Int32 requiredLength) at System.Text.StringBuilder.Append(String value) at Eds.Emi.GeneralDelivery.BusinessLogic.XMLFormattingService.FormattingService.AppendContentMessages(String contractName, Products products) at Eds.Emi.BusinessLogic.ProductDelivererService.DeliverBatchProducts(Task task)

     

    The thing is that we can restart the service and try to run the same request from the application to the database, and it will work again. So it seems like something is not closed or cleaned out after a job is completed?? Anyone been having the same issues?

     

    Regards


    Andreas 

  • 12 years ago

    Hi,

    Generally  System.OutOfMemoryException is occurring when some of the object are used in application but not released after been used. So I think after releaseing all the unnecessary object after been used will help you out from this situation. Some of the tips for releaseing codeing sample..

     using(sqlDataAdapter da=new sqlDataAdapter() )

    {

    //Write down your codeing

    on the above once the sqlDataAdapter has been used, it will realse from the memmory.

    Hope this will help you out. And if any miss information i have posted here, please share with me and help me to correct myself.

     Thanks

    Rajesh

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“The first 90% of the code accounts for the first 90% of the development time. The remaining 10% of the code accounts for the other 90% of the development time.” - Tom Cargill