views:

337

answers:

2

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

+2  A: 

Maybe clearing the cache might help? See NSURLCache class.

Diederik Hoogenboom
thanks for your suggestion Diederik
RAGOpoR
cound you show me some example to clear cache?
RAGOpoR
[[NSURLCache sharedURLCache] removeAllCachedResponses];
Diederik Hoogenboom
i try your code but it not free memory. thanks for your reply
RAGOpoR
+1  A: 

Hi,

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.

deanWombourne
thank for your suggestion deanWombourne
RAGOpoR