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

内存占用 #324

Open
WangYou77 opened this issue Dec 12, 2024 · 3 comments
Open

内存占用 #324

WangYou77 opened this issue Dec 12, 2024 · 3 comments

Comments

@WangYou77
Copy link

是不是缺少释放内存,当并发量跟请求体过大,应用占用的内存会居高不下

@WangYou77
Copy link
Author

以TcpSession为例,是不是缺少一个Flush方法

@toolgood
Copy link

我看了源代码,断开后注销Session代码 如下,

        /// <summary>
        /// Unregister session by Id
        /// </summary>
        /// <param name="id">Session Id</param>
        internal void UnregisterSession(Guid id)
        {
            // Unregister session by Id
            Sessions.TryRemove(id, out TcpSession _);
        }

按你说的没有释放 ,可以改成

        /// <summary>
        /// Unregister session by Id
        /// </summary>
        /// <param name="id">Session Id</param>
        internal void UnregisterSession(Guid id)
        {
            // Unregister session by Id
            Sessions.TryRemove(id, out TcpSession tcpSession);
            if (tcpSession!=null) {
                if (tcpSession.IsDisposed == false) {
                    tcpSession.Dispose();
                }
                tcpSession = null;
            }
        }

@toolgood
Copy link

toolgood commented Mar 3, 2025

还有一点可以减少内存,使用int 代码long ,int占用4个byte,long占用8个byte。而且使用tcp传输文件也不会超800M,足够用了

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

2 participants