i using websockets receive protcol buffers , experiencing memory leak. leak occurs regardless of incoming buffer size , frequency.
the protobufs being received blobs same leak present when receiving arraybuffer. have implemented packet handler sets blob null attempt invoke garbage collection.
my listen call: ws.onmessage.listen(handlepacket);
my event handler: void handlepacket(message) { message = null; }
i don't understand if stream of messageevents in websocket queue not dequeuing processed events, appears memory allocated incoming events fails garbage collected. appreciated.
edit client side code:
void _opensocket() { if (ws == null) { ws = new websocket('ws://localhost:8080/api/ws/open'); // ws.binarytype = "arraybuffer"; } } void _closesocket() { if (ws != null) { ws.close(); print("socket closed"); ws = null; } } void _openstream (string fieldname, [_]) { //check if need open socket _opensocket(); //request proper data map ask = {"request": "stream", "field": fieldname}; if (ws.readystate == 0){ ws.onopen.listen((_) { ws.send(json.encode(ask)); }); } else { ws.send(json.encode(ask)); } activequantities++; if (activequantities == 1) { _listen(); } } // receive data socket _listen() { ws.onerror.listen((_){ print("error"); }); ws.onclose.listen((_){ print("close"); }); ws.onmessage.listen(handlepacket); } void handlepacket(message) { message = null; }
looks dartium expected leak memory, when using dart2js , running in chrome did manage gc, albeit after showing same symptoms in dartium. https://github.com/dart-lang/sdk/issues/26660