From 230de71e3181e13f10cb2742faa833ea4590896c Mon Sep 17 00:00:00 2001 From: Eming Kwok Date: Wed, 7 Dec 2016 17:11:57 -0800 Subject: [PATCH] fix memory leak in Chrome debugging Summary: `RCTWebSocketExecutor` saves every WebSocket callback when sending message to chrome, but does not clear them in a debug session until the JS bridge is reloaded, and there may be thousands of blocks saved in the callback table. This PR removes them after they are called. Closes https://github.com/facebook/react-native/pull/11341 Differential Revision: D4295710 Pulled By: javache fbshipit-source-id: 29a02d1aba320115bbb97aee8981e34b89303c91 --- Libraries/WebSocket/RCTWebSocketExecutor.m | 1 + 1 file changed, 1 insertion(+) diff --git a/Libraries/WebSocket/RCTWebSocketExecutor.m b/Libraries/WebSocket/RCTWebSocketExecutor.m index 09ccbf95e5efe0..cea7ab7fb43147 100644 --- a/Libraries/WebSocket/RCTWebSocketExecutor.m +++ b/Libraries/WebSocket/RCTWebSocketExecutor.m @@ -141,6 +141,7 @@ - (void)webSocket:(RCTSRWebSocket *)webSocket didReceiveMessage:(id)message RCTWSMessageCallback callback = _callbacks[messageID]; if (callback) { callback(error, reply); + [_callbacks removeObjectForKey:messageID]; } }