内存性能和Web服务 [英] Memory Performance and Web Services

查看:81
本文介绍了内存性能和Web服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在尝试了解连接到Web服务时的内存行为。


为了做到这一点,我们创建了一个非常简单的Web服务,其中包含以下Web方法:

 [WebMethod] 
public int AddIntegerss(int a,int b)
{
返回a + b;
}

为了消除高内存的可能原因,Web服务是在发布模式下构建和发布的(没有pdb文件)。同样在Web配置文件中,debug被设置为Off,以及sessionState。


Web服务已在Windows Server 2003上发布–安装了.Net Framework 3.5的SP2。


接下来,我们创建了一个调用此Web方法10,000次的应用程序,并在相应的w3wp进程上监视以下性能计数器: Private字节数,虚拟字节数工作集和  所有堆中的字节数(在.NET CLR内存性能中)


如下表所示,似乎所有堆中的私有字节和#字节以相同的速率增加,这意味着托管内存而不是本机内存增加(http://msdn.microsoft.com/en-us/library/ee817660.aspx )。





< tbody>




























































































 



。NET CLR Memory



w3wp Process



时间



所有堆中的#Bytes



私有字节



虚拟字节



工作集



11:30:17



3,521,012



31,600,640



569,507,840



35,958,784



11:30:32



3,521,012



31,600,640



569,507,840



35,962,880



11:30:47



4,735,932



< p style ="text-align:right"align = right> 41,451,520



569,585,664



47,374,336



11:31:02



4,878,652



43,079,744



569,585,664



49,651,712



11:31:17



5,018,084



44,169,568



< span style ="font-size:10pt; font-family:Arial"> 569,585,664



50,266,112



11:31:32



5,167,180



44,335,104



569,585,664



50,376,704



11:31:47



5,308,440



44,777,472



570,109,952



50,847,744



11:32:02



5,404,064



45,047,808



570,109,952



51,142,656



11:32:17



5,404,064



45,031,424



569,847,808



51,138,560



11:32:32



5,404,064



45,015,040



569,585,664



51,130,368


           

然而,与有限的内存分配相比,内存的增加相当大网络方法要求。此外,即使经过相当长的时间后,这些私有字节似乎也没有被分配,如下表所示。
































 



。NET CLR Memory



w3wp Process



时间



所有堆中的#字节



私有字节



虚拟字节



工作集



11:32:02



5,404,064



45,047,808



570,109,952



51,142,656



11:43:17



5,466,404



44,929,024



569,323,520



51,060,736



这是我们能够做出的唯一结论。但我们仍然不了解幕后背后的真实情况,为什么内存会增加很多。


请提供建议。

解决方案

我建​​议使用适用于ASP.NET / IIS的内存分析器工具,如Scitech的.NET内存分析器,以获取特定于您的部署的信息。 


We are trying to understand the memory behavior when connecting to a web service.

In order to do so, we created a very simple Web service that contains the following web method:

[WebMethod]
public int AddIntegerss(int a, int b)
{
return a + b;
}

To eliminate possible reasons for high memory, the web service was built and published in Release Mode (with no pdb files). Also in the web config file, debug was set to Off, as well as the sessionState.

The web service was published on a Windows Server 2003 – SP2 with .Net Framework 3.5 installed.

Next, we created an application that calls this web method 10,000 times, and we monitored the following Performance Counters on the corresponding w3wp process: Private Bytes, Virtual Bytes , Working Set, and  Number of bytes in all heaps (in .NET CLR Memory Performance)

As the table shows below, it seems that the private bytes and # bytes in all Heaps are increasing at the same rate, which implies an increase in the managed memory rather than the native memory (http://msdn.microsoft.com/en-us/library/ee817660.aspx ).


 

.NET CLR Memory

w3wp Process

Time

# Bytes in all Heaps

Private Bytes

Virtual Bytes

Working Set

11:30:17

3,521,012

31,600,640

569,507,840

35,958,784

11:30:32

3,521,012

31,600,640

569,507,840

35,962,880

11:30:47

4,735,932

41,451,520

569,585,664

47,374,336

11:31:02

4,878,652

43,679,744

569,585,664

49,651,712

11:31:17

5,018,084

44,269,568

569,585,664

50,266,112

11:31:32

5,167,180

44,335,104

569,585,664

50,376,704

11:31:47

5,308,440

44,777,472

570,109,952

50,847,744

11:32:02

5,404,064

45,047,808

570,109,952

51,142,656

11:32:17

5,404,064

45,031,424

569,847,808

51,138,560

11:32:32

5,404,064

45,015,040

569,585,664

51,130,368

           

However the increase in memory is quite large compared to the limited memory allocation that the web method requires. Furthermore, it doesn’t seem that these private bytes are de-allocated even after a considerable amount of time as shown in the table below.

 

.NET CLR Memory

w3wp Process

Time

# Bytes in all Heaps

Private Bytes

Virtual Bytes

Working Set

11:32:02

5,404,064

45,047,808

570,109,952

51,142,656

11:43:17

5,466,404

44,929,024

569,323,520

51,060,736

These are the only conclusions we were able to make. But we still don’t understand what is really happening behind the scene and why is the memory increasing that much.

Please advice.

解决方案

I would recommend to use a memory profiler tool, such as Scitech's .NET memory profiler, that works for ASP.NET/IIS, to get information specific to your deployment. 


这篇关于内存性能和Web服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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