wendux / DSBridge-IOS

:earth_asia: A modern cross-platform JavaScript bridge, through which you can invoke each other's functions synchronously or asynchronously between JavaScript and native.
1.96k stars 305 forks source link

异步调用可能产生内存泄露 #69

Closed Leon0317 closed 5 years ago

Leon0317 commented 5 years ago

目前在使用的是3.0.2版本。 在DWKWebView中执行到 -(NSString *)call:(NSString*) method :(NSString*) argStr 这一方法时,在266行定义completionHandler时,block中使用了self,而后把这个completionHandler作为用户自定义的异步方法的参数传给了JavascriptInterfaceObject对象。这个情况可能会造成DWKWebView对象长时间被强引用不能释放,导致一些内存检测机制告警。 我在定义这个completionHandler使用weak-strong dance处理了一下,检测不到内存泄露了。 希望在新版本中能评估一下这个问题。

wendux commented 5 years ago

如果需要改库源码得话,可以提个PR;如果是使用方式上该注意的问题,可以贴出你的代码供大家参考。

GuoMingJian commented 4 years ago

用了这个sdk,线上包一直闪退报错,大神能解决下么?

SEGV_ACCERR

出错堆栈 0 ??? 000000000000000000

sjustfly commented 4 years ago

SEGV_ACCERR

出错堆栈 0 ??? 000000000000000000

0 1 Foundation +[_NSJSONReader validForJSON:depth:allowFragments:] + 72 2 Foundation ___51+[_NSJSONReader validForJSON:depth:allowFragments:]_block_invoke + 96 3 CoreFoundation _NSDICTIONARY_IS_CALLING_OUT_TO_A_BLOCK + 16 这个问题有解决么,我这边也是一直报错