kerryjiang / WebSocket4Net

A popular .NET WebSocket Client
752 stars 272 forks source link

Memory leak on sending byte array #119

Open Grimones opened 6 years ago

Grimones commented 6 years ago

I'm trying to send a byte array which contains depth frame of kinect v2. I'm sure, that memory leak isn't caused by the way how i'm working with byte array because before i was using SocketIoClientDotNet and ram usage was not exceeding even 100MB and GC was working constantly. After i have changed to WebSocket4Net i'm experiencing the issue. GIF On 247MB i have turned off sending and then resumed again. And you can see that interval between GC increases from the start. Depth frame size is 512*424*2 (2 bytes per pixel) = 434176. Also i have depth frame quiality which simply ingnores every nth pixels. So the memory leak also appears even on capturing evey 8 pixel, 434176 / 8 = 54272. But much slower than on full frame.

GC starts to work after exceeding 600mb. GIF. However memory usage constantly increases. Code is pretty simple.

private void Send(byte[] data)
        {
            _webSocket.Send(data, 0, data.Length);
        }

Using latest version of WebSocket4Net - 0.15.1 SuperSocket.ClientEngine.Core - 0.9.0