housenkui / JavascriptBridge

More simple more light more easy to use for iOS/OSX bridge with Javascript. Also easy to get js console.log in Xcode.
MIT License
84 stars 11 forks source link

WKWebView Not getting dealloc'ed #1

Open saru2020 opened 4 years ago

saru2020 commented 4 years ago

Hi,

A great library for logging purposes. There is one issue where if the logs are enabled then it holds onto the webview's instance which leads to memory leaks.

housenkui commented 4 years ago

Hi, Very thanks to use the library. And i had add a class named "SKWebView" to test whether will leads to memory leaks . But when i leave the "ExampleWKWebViewController" and the function

- (void)dealloc {
    NSLog(@"SKWebView dealloc ");
}

in "SKWebView" was called.

I had pushed the last code, and you can open finder "TestPod" to have a try。@saru2020

saru2020 commented 4 years ago

Its a great library and very much useful, thanks for creating it. Thanks for the sample. Yes, the dealloc of the controller is called when you leave it. Please check the same flow in the Instruments/Leaks/Allocations app and you’ll see that only the WKWebView and its interlinked objects alone aren’t getting dealloc’ed. I didn’t look into your implementation but something’s holding onto the WKWebView’s instance specifically. Note: I didn’t try your sample but saying this by testing it from my own project and only after removing the entire library, I saw the webview’s instances getting released, probably, there is something wrong with the run time apis working with the webview apis.

Thanks! Saravanan Sent from my iPhone(Please excuse any typos)

On 02-May-2020, at 11:19 AM, Daves_Hou notifications@github.com wrote:

 Hi, Very thanks to use the library. And i had add a class named "SKWebView" to test whether will leads to memory leaks . But when i leave the "ExampleWKWebViewController" and the function

  • (void)dealloc { NSLog(@"SKWebView dealloc "); } in "SKWebView" was called.

I had pushed the last code, and you can open finder "TestPod" to have a try。@saru2020

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

housenkui commented 4 years ago

Dear friend,It‘s my pleasure. How wonderful of the world in github! SKWebview is the Subclass of WKWebview. The dealloc of the SKWebview is called when you leave secondViewcontroller. And i use instruments/Leaks/Allocations test for "TestPod" (DEMO) in the library. The video url is : https://www.youtube.com/watch?v=mngmT-2xrgk I did not found something wrong?

Dear friend, are you ok in your project?