Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hitting a memory limit slows down the .Net application

We have a 64bit C#/.Net3.0 application that runs on a 64bit Windows server. From time to time the app can use large amount of memory which is available. In some instances the application stops allocating additional memory and slows down significantly (500+ times slower).When I check the memory from the task manager the amount of the memory used barely changes. The application keeps on running very slowly and never gives an out of memory exception. Any ideas? Let me know if more data is needed.

like image 824
derdo Avatar asked Dec 07 '22 03:12

derdo


1 Answers

You might try enabling server mode for the Garbage Collector. By default, all .NET apps run in Workstation Mode, where the GC tries to do its sweeps while keeping the application running. If you turn on server mode, it temporarily stops the application so that it can free up memory (much) faster, and it also uses different heaps for each processor/core.

Most server apps will see a performance improvement using the GC server mode, especially if they allocate a lot of memory. The downside is that your app will basically stall when it starts to run out of memory (until the GC is finished).

* To enable this mode, insert the following into your app.config or web.config:

<configuration>
   <runtime>
      <gcServer enabled="true"/>
   </runtime>
</configuration>
like image 65
Aaronaught Avatar answered Feb 22 '23 12:02

Aaronaught