【发布时间】:2017-10-05 06:04:42
【问题描述】:
我正在我的 react-native 应用程序中使用 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;
}
下面是内存图。
【问题讨论】:
标签: react-native three.js uiwebview