Android webview Memory Leak clue

Source: Internet
Author: User

Http://stackoverflow.com/questions/3130654/memory-leak-in-webview


I conclude from abve comments and further tests, that the problem is a bug in the SDK: when creating a webview via XML layout, the activity is passed as the context for the webview, not the application context. when finishing the activity, the webview still
Keeps references to the activity, therefore the activity doesn't get removed from the memory. I filed a bug report for that, see the link in the comment above.

webView = new WebView(getApplicationContext());
Share | Edit Answered Jun 28 '10

Mathias Lin
11.8k44284
 
1  
Ty for that getapplicationcontext () actually worked on my memory leak when creating the webview. But when I add the webview to another
Viewgroup the Memory Leak appears again. My wild guess is that adopts the parent's basecontext. Is there anyworkaround to that? I create the parent with getapplicationcontext () too... so I guess I'm out of theories-weakwire Sep
20 '11
4  
Note that using the application context means that you won't be able to click on links in your webview, since doing so will result
In a crash: "calling startactivity () from outside of an activity context requires the flag_activity_new_task flag. Is this really what you want? "-Emmby Jan
20'12
  @ Emmby thanks for the hint, wasn' t thinking of that, as I just needed the webview to display more complex HTML (beyond what you can
Do with a textview), but no links in it. Therefore, I didn't come into ss the issue you mentioned, but thanks for pointing it out again. + 1-Mathias
Lin Jun
18 '12
2  
Also, any time the webview attempts to create a dialog (e.g., to remember a password, etc), the webview will crash as it expects
Activity context.-markshiz Aug
30'12
1  
It crush app when webview want to display Dialog for example asking "do you want save passwaord" then it will crush-gelldur Dec
30'12 at 20:52

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.