is it possible to free memory of UIWebView?

前端 未结 3 1460
醉话见心
醉话见心 2021-01-03 11:38

i\'m trying to release UIWebView object but it not free memory. is it have any reason?

3条回答
  •  长情又很酷
    2021-01-03 12:17

    Just because you've released it doesn't mean that it can be released - maybe it's being used by something else?

    What is it's retain count after you have freed it?

    [myWebView release];
    NSLog(@"%i", [myWebView retainCount]);
    

    If this number is not 0, someone else is retaining it as well and it can't be freed until they release it too (or it's set to be autoreleased so it will vanish at some point in the future).

    Another possibility is that the memory used is in some sort of shared library that gets loaded when a web view is created - you'll probably get no control of how to unload that.

    Sam

    PS I'm assuming that you've also done [myWebView removeFromSuperview]; - adding yourself to a view will retain you.

提交回复
热议问题