facebookincubator / SocketRocket

A conforming Objective-C WebSocket client library.
Other
9.56k stars 2.01k forks source link

Fix memory leak by freeing mutex. #469

Closed kwgithubusername closed 8 years ago

kwgithubusername commented 8 years ago

Instruments shows a leak of category Malloc 64 Bytes from SRMutexInitRecursive after re-initializing a SRWebSocket property.

I have an app that uses a SRWebSocket property for a few different subscriptions that need to be active at different times. As a temporary solution I am manually closing the socket to unsubscribe from everything and re-initializing the socket since I can only call open on each instance once.

After calling free on mutex, the memory leak no longer appears in Instruments.

nlutsenko commented 8 years ago

Hey @woudini, thanks for the contribution! This is an amazing catch! You are absolutely right, there is a need to free the mutex after it is destroyed. Will merge in after the tests pass.

kwgithubusername commented 8 years ago

Awesome, thanks @nlutsenko for the quick reply!