websocket-sharp icon indicating copy to clipboard operation
websocket-sharp copied to clipboard

memory leak

Open ShangQuX opened this issue 6 years ago • 8 comments

  1. The client is WebSocket of JavaScript.There are 5,000-8,000 connections, and clients often close or break unexpectedly (tabs are closed).WebSocketServer runs for about 2 days, when the memory usage exceeds 1GB, there will be a memory overflow.WebSocketServer USES Secure Connection.
  2. When the number of connections is not at its peak, memory does not drop, but slowly increases.
  3. When the number of connections is large, websocketserver.stop can be time-consuming (at least more than 2 minutes).

ShangQuX avatar Nov 06 '19 06:11 ShangQuX

我遇到和你一样的状况,请问大侠解决了吗?你有没有把KeepClean设为false?

ntminer avatar Jan 11 '21 17:01 ntminer

我遇到和你一样的状况,请问大侠解决了吗?你有没有把KeepClean设为false?

No,"KeepClean=true”, I have abandoned using this component, I change to another component. component name “SuperSocket”,A single service supports 10,000+ connections。 https://github.com/kerryjiang/SuperSocket

ShangQuX avatar Jan 12 '21 00:01 ShangQuX

我试了,但是这个SuperWebSocket对WebSocket协议的实现有问题,由于业务上我无法升级客户端请求的协议导致不能用这个SuperWebSocket服务端。

ntminer avatar Jan 12 '21 06:01 ntminer

我试了,但是这个SuperWebSocket对WebSocket协议的实现有问题,由于业务上我无法升级客户端请求的协议导致不能用这个SuperWebSocket服务端。

SuperSocket contains SuperWebSocketServer and supports WebSocket Secure Connections (TLS1 --TLS1.3). To support TLS1.3, you need to upgrade SuperSocket (v1.6.6) to.NET 4.8. config file content contains <security="Default, Tls11, Tls12, Tls13"> doc: https://docs.supersocket.net/v1-6/zh-CN

ShangQuX avatar Jan 12 '21 07:01 ShangQuX

我试了,但是这个SuperWebSocket对WebSocket协议的实现有问题,由于业务上我无法升级客户端请求的协议导致不能用这个SuperWebSocket服务端。

Chorme browser 79+ version, enabled WebSocket secure connection as TLS1.3, The SuperSocket (V1.6.6) framework is.NET 4.5, which only supports TLS1.2. You need to upgrade the SuperSocket framework to.NET 4.8. If you use SuperSocket (V2.0), there is no problem.

ShangQuX avatar Jan 12 '21 07:01 ShangQuX

感谢帮忙,我还没用过4.8,暂时升级不了。我准备读一下WebSocketSharp的代码找找看哪里内存泄露的。

ntminer avatar Jan 12 '21 07:01 ntminer

解决了,Ext.ReadBytesAsync中有一个var dest = new MemoryStream ()未释放导致的内存泄露。

ntminer avatar Jan 13 '21 14:01 ntminer

解决了,Ext.ReadBytesAsync中有一个var dest = new MemoryStream ()未释放导致的内存泄露。

bro how fix it ?

ilsnk avatar May 14 '22 09:05 ilsnk