Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory leak #89

Open
NikeKey opened this issue Oct 27, 2023 · 1 comment
Open

Memory leak #89

NikeKey opened this issue Oct 27, 2023 · 1 comment

Comments

@NikeKey
Copy link

NikeKey commented Oct 27, 2023

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
Copy link
Author

NikeKey commented Oct 27, 2023

  • Net.4.8.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant