Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 每个客户端的WCF CPU使用率增加25%_C#_.net_Wcf - Fatal编程技术网

C# 每个客户端的WCF CPU使用率增加25%

C# 每个客户端的WCF CPU使用率增加25%,c#,.net,wcf,C#,.net,Wcf,正如标题所说,我得到了一个定义了以下服务行为的WCF服务器: [ServiceBehavior(InstanceContextMode = InstanceContextMode.Single, ConcurrencyMode = ConcurrencyMode.Multiple)] 我正在使用命名管道绑定,我的客户端正在以这种方式连接: NetNamedPipeBinding binding = new NetNamedPipeBinding(); const int maxValu

正如标题所说,我得到了一个定义了以下服务行为的WCF服务器:

[ServiceBehavior(InstanceContextMode = InstanceContextMode.Single, ConcurrencyMode = ConcurrencyMode.Multiple)]
我正在使用命名管道绑定,我的客户端正在以这种方式连接:

    NetNamedPipeBinding binding = new NetNamedPipeBinding();
const int maxValue = 0x40000000; // 1GB
binding.MaxBufferSize = maxValue; 
binding.MaxReceivedMessageSize = maxValue;

binding.ReaderQuotas.MaxArrayLength = maxValue;
binding.ReaderQuotas.MaxBytesPerRead = maxValue;
binding.ReaderQuotas.MaxStringContentLength = maxValue;

// receive timeout acts like a general timeout
binding.ReceiveTimeout = TimeSpan.MaxValue;
binding.SendTimeout = TimeSpan.MaxValue;

ChannelFactory<IDatabaseSession> pipeFactory = new ChannelFactory<IDatabaseSession>(binding, new EndpointAddress("net.pipe://localhost/DatabaseService"));

IDatabaseSession dbSession = pipeFactory.CreateChannel()
NetNamedPipeBinding=newnetnamedpipebinding();
常量int maxValue=0x40000000;//1GB
binding.MaxBufferSize=maxValue;
binding.MaxReceivedMessageSize=maxValue;
binding.ReaderQuotas.MaxArrayLength=maxValue;
binding.ReaderQuotas.MaxBytesPerRead=maxValue;
binding.ReaderQuotas.MaxStringContentLength=maxValue;
//接收超时的行为类似于一般超时
binding.ReceiveTimeout=TimeSpan.MaxValue;
binding.SendTimeout=TimeSpan.MaxValue;
ChannelFactory pipeFactory=新的ChannelFactory(绑定,新端点地址(“网络”)。pipe://localhost/DatabaseService"));
IDatabaseSession dbSession=pipeFactory.CreateChannel()
我启动的每个客户机都执行上面的代码,每个客户机的CPU使用率都会提高25%(实际上不是5.client,但此时服务可执行性几乎覆盖了整个CPU容量的100%)

我搜索的是一种资源(网站/列表或您的强大知识),告诉我CreateChannel实际做了什么(关于资源分配问题)


提示:即使没有实际进行通信,CPU使用率也会增加,只是创建了通道

暂停调试器并查看所有线程已暂停的位置。这可能是代码中最热门的部分。查看调用堆栈。

WCF本身不太可能使用那么多资源,特别是因为您说过即使在没有通信的情况下也会发生这种情况。我猜这是服务的问题,而不是客户的问题。如果您有服务构造函数,请查看它。还可以尝试使用不同的
InstanceContextMode
ConcurrencyMode

值。我预测您有4个内核和一些正在紧密循环中运行的东西。学习使用调试器和/或CPU探查器。实际上,您是对的。4个内核和一些至今未找到的小循环…这是我的服务管理的dll的一个问题。。。实际上没有客户问题。