New issue
Advanced search Search tips

Issue 803789 link

Starred by 2 users

Issue metadata

Status: WontFix
Owner: ----
Closed: Feb 2018
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Android
Pri: 2
Type: Bug



Sign in to add a comment

The size of native heap is still very large even after removing WebView

Reported by fanjins...@sogou-inc.com, Jan 19 2018

Issue description

Steps to reproduce the problem:
1. Create 20 WebViews and load url https://m.sohu.com,
2. After loading finish, delete all WebViews.

What is the expected behavior?
The native heap will be released to the size before creating WebView.

What went wrong?
The size of native heap is still very large even after removing WebView

Did this work before? N/A 

Chrome version: 63.0.3239.111  Channel: stable
OS Version: 7.1.1 N6F27I
Flash Version: N/A

I create a demo APK that contains a Activity, three Buttons.
LOAD LIBRARY Button: 
Call WebSettings.getDefaultUserAgent(Context) to preload WebView's native library;

CREATE WEBVIEW Button: Create 20 WebViews, and load https://m.sohu.com;

DELETE WEBVIEW Button: Destroy all WebViews.

During these operations, I use "adb shell dumpsys meminfo com.demo.multiwebview.multiwebview" to monitor Native Heap.
It grew a lot, decreased a little.
How can I release Native heap after removing WebView?
The attachments are my demo APK and meminfo.
 
Demo.apk
1.4 MB Download
multiwebview.mem
212 KB Download
My device is Nexus 6.
Labels: Needs-triage-Mobile
Cc: pnangunoori@chromium.org
Components: Mobile>WebView
Labels: Needs-Feedback Triaged-Mobile
fanjinsong@ -- Thanks for reporting this issue along with the demo file. Upon trying to install the Demo.apk file, observed an Error " Sorry, only *.cfg and *.config file can be added." on Pixel 2 and Pixel XL Android 8.1.0 devices. Could you please help us in providing an another demo file along with the screencast for better understanding.

You can also try by updating your Chrome to latest stable #64.0.3282.137.

Thanks in advance!

Comment 4 by torne@chromium.org, Feb 13 2018

Status: WontFix (was: Unconfirmed)
There's no way to unload WebView after using it. Sorry - there isn't anything we can do, unfortunately; the whole of chromium is simply not designed to ever be shut down. If you've called WebView.destroy() on each and then removed references to them, that's as much memory as you are going to get back until your process is killed by the system.
Thanks Torne.
In my demo, I call WebView.destroy() and remove all references to them.
If I can call AwContents.TrimMemory() by TRIM_MEMORY_MODERATE level, does it make sense? I try call AwContents.TrimMemory() by TRIM_MEMORY_MODERATE level before WebView.destroy() on my locally build, while it takes up almost no memory changes.

Sign in to add a comment