(a lot) UIWebView memory leak

I have seen from other posts that there are problems with memory leaks with UIWebView. However, with the number of objects that flow through me, I need to wonder if I am not doing something wrong. "Leaks" reports 60 leaks for opening UIWebView, loading the page and closing (this is the Facebook login page). I check the stack trace for each of these objects and they never touch my code. They are all either in a separate thread (I use only the main thread), or go from "main" to a bunch of internal methods that are grayed out. Is this expected from UIWebView? I am running the latest firmware, and I think they have already fixed this. By the way, I see this on the device. I also tried to check for errors on the apple website, but there is no way to search other than the problem identifier.?

Sean

This is where leaks are captured:

enter image description here

0
source share
2 answers

Sorry to answer my question so quickly, but I just found the problem.

If you return NO for the delegate method:

- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType;

and then release the UIWebView, it will leak as described above. Return YES resolves the issue. At least for me, this happens in all versions of the firmware to date (4.3.3). I am logging a bug with Apple.

+1
source

Fellows! I know a little later%) I researched this topic for a while and found a solution that works best for me - use WKWebView, it does not flow! It is so simple.

0
source

Source: https://habr.com/ru/post/1544835/


All Articles