chronoxor / CppServer

Ultra fast and low latency asynchronous socket server & client C++ library with support TCP, SSL, UDP, HTTP, HTTPS, WebSocket protocols and 10K connections problem solution
MIT License
1.43k stars 284 forks source link

Memory leak #89

Open NikeKey opened 1 year ago

NikeKey commented 1 year ago

When i use https://github.com/chronoxor/CSharpServer Test With Repeat: 10 Thread/Connect: 100 Message send and echo: 10

image On screen - ChatSession never Disposed. (But I try manual call Dispose, and GC.Collect) Then if disassembly in VS2022: session.Dispose:

    public sealed override void Dispose()
    {
        Dispose(A_0: true);
        GC.SuppressFinalize(this);
        GC.KeepAlive(this);
    }

I think problem in this: GC.KeepAlive(this); - autogenerate because in C++ code -> CreateSession return std::make_shared ; this bad idea for c# (and other code for dispose) https://habr.com/ru/articles/509004/

I looked in .Net Momory Profiler leak this: image

NikeKey commented 1 year ago