如何释放本机Webview内存

问题描述 投票:3回答:1

我正在本机应用程序中使用WebView加载Three.JS模型。加载模型后,内存会增加。

现在,当我点击按钮时,我想取消分配webView组件并释放内存。

或当我进入下一个屏幕时,我想释放内存。

下面是我的代码。

{this.state.showWebview &&
        <WebView
            ref={(wbref) => {
              this.webview = wbref;
            }}
            style={styles.middleview}
            source={{
              uri: this.state.showWebview && this.props.isCurrentScreenOnTop
              ? '3DMODEL/vechicle.html'
              : null,
            }}
            onLoadStart={this.onLoadStart}
            onLoad={this.onLoad}
            onLoadEnd={this.onLoadEnd}
            onError={this.onError}
            renderError={this.renderError}
            onMessage={this.handleMessageFromBuilder}
            cacheEnabled={false}
            cookiesEnabled={false}
        />}

componentWillUnmount() {
    this.webview = null;
}

下面是内存图。

enter image description here

react-native three.js uiwebview
1个回答
1
投票

添加道具

useWebkit={true}然后内存会分配一点。

© www.soinside.com 2019 - 2024. All rights reserved.