Avoid memory leak in RCTWebSocketModule
Summary: Though this module is dev-only, if not connected to the packager it will collect websockets forever. Some estimate it'll take up 200MB after like 20 minutes. Reviewed By: shergin Differential Revision: D6464304 fbshipit-source-id: bef1ce967e4c13dd29e3c7ab4228e9c88d02c157
This commit is contained in:
parent
ad4450ac13
commit
1e1e491246
|
@ -163,6 +163,7 @@ RCT_EXPORT_METHOD(close:(nonnull NSNumber *)socketID)
|
|||
{
|
||||
NSNumber *socketID = [webSocket reactTag];
|
||||
_contentHandlers[socketID] = nil;
|
||||
_sockets[socketID] = nil;
|
||||
[self sendEventWithName:@"websocketFailed" body:@{
|
||||
@"message": error.localizedDescription,
|
||||
@"id": socketID
|
||||
|
@ -176,6 +177,7 @@ RCT_EXPORT_METHOD(close:(nonnull NSNumber *)socketID)
|
|||
{
|
||||
NSNumber *socketID = [webSocket reactTag];
|
||||
_contentHandlers[socketID] = nil;
|
||||
_sockets[socketID] = nil;
|
||||
[self sendEventWithName:@"websocketClosed" body:@{
|
||||
@"code": @(code),
|
||||
@"reason": RCTNullIfNil(reason),
|
||||
|
|
Loading…
Reference in New Issue