出于对IIS内存异常 [英] Out Of memory Exception in IIS

查看:293
本文介绍了出于对IIS内存异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须有一个具有MVC模板,并使用REST的应用程序。
说我有一个REST调用制成,它击中特定的方法

I have have an application that has MVC template and uses REST . Say I have a rest call made and it hits the particular method

    void sample function() {
   // connects to db through entity framework
   // retrieves data and embeds in to list
   //returns JSON of data received.
   }



所以这里的问题是我测量了运行程序内存。它是关于说40,000kb。现在,当我再举一个REST调用内存不IIS.It清理从开始的 40,000kb 而不是zero.finally如果我像3或4调用有内存溢出异常。所以每次通话后,我需要IIS的内存被清理,而是保留了上一个呼叫的记忆。我怎样才能释放内存的所有以前的电话made.I已通过配置模型和所有其他可能性,尝试过各种解决方案。该解决方案似乎,如果部署在当地,而不是IIS工作。有人可以帮我?

So the problem here is I measured the memory it took to run the program . it was about say 40,000kb. Now when i give another rest call the memory is not cleaned in IIS.It starts from 40,000kb instead of zero.finally if i make like 3 or 4 calls there is Out of Memory Exception. So after every call i need the IIS memory to be cleaned up,instead it retains the memory for the previous call. How can i release memory for all the previous calls made.I have tried various solution by disposing model and all other possibilities. The solution seem to Work if deployed on local instead of IIS. Can some one please help me?

推荐答案

如果垃圾收集是解决方案,一个简单的GC.Collect的往往非充分,并为性能原因,应该只有在真正需要调用。请尝试以下步骤调用垃圾时可用内存太低(低于作为过程参数提供的阈值)。

If garbage collection is the solution, a simple GC.Collect is often unsufficient and, for performance reason, it should only be called if really required. Try the following procedure that calls the garbage when the available memory is too low (below the threshold provided as procedure parameter).

internal static void CollectGarbage(int SizeToAllocateInMo)
{
       long [,] TheArray ;
       try { TheArray =new long[SizeToAllocateInMo,125000]; }low function 
       catch { TheArray=null ; GC.Collect() ; GC.WaitForPendingFinalizers() ; GC.Collect() ; }
       TheArray=null ;
     }

这篇关于出于对IIS内存异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆