微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

在 setInterval 中,异步函数进入队列并使应用程序因内存泄漏而冻结,在 javascript 中

如何解决在 setInterval 中,异步函数进入队列并使应用程序因内存泄漏而冻结,在 javascript 中

在 setInterval 中,异步函数进入队列并使应用程序因内存泄漏而冻结,在 javascript 中

//在我正在使用的函数下方。

setIntervalsForServices = async (
  forkDevice,forkParsedData,shockDevice,shockParsedData ) => {

    this.manager.stopDeviceScan();

    let startTimestamp = Date.Now()
    let counter = -1;

    console.log("startTimestamppp",startTimestamp)

    let localForkEachFrequencyPerSecondarrayData = [];
    let localShockEachFrequencyPerSecondarrayData = [];

    let localForkTotalFrequencyValue = [];
    let localShockTotalFrequencyValue = [];

    if (this.state.recordingStart) {
        this.baseSecondInterval = setInterval(() => {
            let forkFrequencyIncremental = 0;
            let shockFrequencyIncremental = 0;
            let frequencyIncremental = 0;
            let baseFrequencyIntervalTime = this.state.frequency > 0 ? parseInt(1000 / this.state.frequency) : 1000

            var root = this
            counter++
            if (this.state.recordingStart) {
                this.baseFrequencyIntervalArray[counter] = setInterval((localCounter) => {
                    let currentTimestampX = Date.Now() - startTimestamp;

                    forkFrequencyIncrementaL++;
                    shockFrequencyIncrementaL++;
                    frequencyIncrementaL++;

                    console.log("Data in inner setinterval ",this.baseFrequencyIntervalArray,localCounter)

// 在 React-Native 中获取队列并使应用程序冻结的 setinterval 之后调用异步函数 // 读取特征

                    this.setcharacteristicsToFetchData(
                        forkDevice,shockParsedData,currentTimestampX,localCounter,localForkEachFrequencyPerSecondarrayData,localShockEachFrequencyPerSecondarrayData,localForkTotalFrequencyValue,localShockTotalFrequencyValue,this.baseFrequencyIntervalArray[counter]
                    )
                },this.state.frequency > 0 ? parseInt(1000 / this.state.frequency) : 1000,counter)
            }

            this.setState({
                xData: this.state.xData + 1
            })
                        },1000)
    }
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。