memory leak in when working with URLSession webSocketTask
introductory command line app, mac os Ventura 13.2.1
the first leak is fixed on the URLSessionWebSocketDelegate delegate func urlSession(_ session: URLSession, webSocketTask: URLSessionWebSocketTask, didOpenWithProtocol protocol: String?)
further when calling receive closures or through func receive() async throws -> URLSessionWebSocketTask.Message
the system is constantly leaking memory
In order to understand how sad everything is, I recommend opening 20-50 sockets in parallel for large data streams, as an example, financial exchanges
per day of work, 0.2-1 gigabytes of leakage will accumulate
there is one suggestion, maybe it will help fix the bug, it is connected with another leak in the system that appears in the absence of user interactions,
example if we create 20-50 swiftUI labels and start updating them fast enough 5-10 times per second and stop interacting with the mouse, keyboard and touchbar, we will get a memory leak when the old label data is not destroyed by the system - and without touching the keyboard, the mouse in an hour several gigabytes will leak us, then if you move the mouse or press a button on the keyboard, the system will clear the memory