react-native-windows icon indicating copy to clipboard operation
react-native-windows copied to clipboard

Memory leak issue in UWP

Open scott108 opened this issue 9 years ago • 2 comments

Environment

  1. react-native -v: 0.50.3
  2. npm ls rnpm-plugin-windows: 0.2.8
  3. npm ls react-native-windows: 0.50.0-rc2
  4. node -v: 7.7.4
  5. npm -v: 4.1.2

Then, specify:

  • Target Platform: UWP
  • Target Platform Version(s): 10.0.14393
  • Target Device(s): Desktop x64
  • Development Operating System: Windows
  • Visual Studio Version: Visual Studio 2017

Steps to Reproduce

export default class App extends Component<{}> {
  constructor(props) {
    super(props);
    this.state = {
      data: [],
      test: true
    }
    this.syncDataFromServ = this.syncDataFromServ.bind(this);
  }

  async getMoviesFromApi() {
    try {
      
      let response = await fetch('https://facebook.github.io/react-native/movies.json');
      let responseJson = await response.json();
      
      return responseJson.movies;
    } catch(error) {
      console.error(error);
    }
  }

  async syncDataFromServ() {
    let data = await this.getMoviesFromApi();
    this.setState({data});
    this.setState({test: !this.state.test});
  }

  componentWillMount() {
    setInterval(this.syncDataFromServ, 2000);
  }

  render() {
    return (
      <View style={styles.container}>
        <FlatList
          data={this.state.data}
          renderItem={({item}) => <Text>{this.state.test? item.title: item.releaseYear}</Text>}
          keyExtractor={(item, index) => index}
        />
      </View>
    );
  }
}

Expected Behavior

It should trigger garbage collection.

Actual Behavior

It seems like memory leak happened

Reproducible Demo

1511715684536

scott108 avatar Nov 26 '17 17:11 scott108

After 8 hours, it increases to 3000mb

scott108 avatar Nov 27 '17 01:11 scott108

We are not investing in new features or lower priority bug fixes on vCurrent. The bulk of investment is now in vNext as we prepare to make that the default choice. If this issue is still relevant on the vNext implementation please open a vNext issue. If this issue is of significant severity for a vCurrent app and vNext is not an option, re-open with justification.

ghost avatar Oct 25 '19 21:10 ghost