https://bz.apache.org/bugzilla/show_bug.cgi?id=62633

--- Comment #3 from saiya <1005136...@qq.com> ---
(In reply to Mark Thomas from comment #1)
> The provided sample application does not demonstrate a memory leak in Apache
> Tomcat. WsSession objects are retained while the session is open and
> released once the session is closed.
> 
> The provided sample application does contain several memory leaks due to the
> failure to stop threads.

If I execute the following code in the onClose, I can solve it.

try {
            Field wsFrame = WsSession.class.getDeclaredField("wsFrame");
            wsFrame.setAccessible(true);
            WsFrameServer wsFrameServer = (WsFrameServer)
wsFrame.get(wsSession);

            Field socketWrapper =
WsFrameServer.class.getDeclaredField("socketWrapper");
            socketWrapper.setAccessible(true);
            SocketWrapperBase socketWrapperBase = (SocketWrapperBase)
socketWrapper.get(wsFrameServer);

            Field endpoint =
SocketWrapperBase.class.getDeclaredField("endpoint");
            endpoint.setAccessible(true);
            AbstractEndpoint abstractEndpoint = (AbstractEndpoint)
endpoint.get(socketWrapperBase);
            NioEndpoint nioEndpoint = (NioEndpoint)abstractEndpoint;

            AbstractEndpoint.Handler handler = nioEndpoint.getHandler();
            handler.release(socketWrapperBase);

        } catch (IllegalAccessException | NoSuchFieldException e) {
            e.printStackTrace();
        }

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to