itinance / itinance/react-native-fs
[BUGS:] Memory leak and application crash on reading a large file
- Dominant language
- C++
- Stars
- 5k
- Forks
- 1k
- PR merge metrics
- No merged PRs in 30d
Description
Hi !
Problem:
Memory leak and application crash
System:
react-native: 0.59.9
react: 16.9.0
react-native-fs: 2.14.1
iPad: 12.1
Xcode: 11.0
I can’t understand why there is a memory leak and application crash when reading a large file using the read() function
Example test code:
onReadAssets = async () => {
const url = `${node.asset.url}` // <—— Large file
for (let i = 0; i < 1000; i++) {
await RNFS.read(url, 16777216, 0, 'base64').then((data) => { // 16777216 - 16MB chunk, 0 - start seek
console.log('Read file', i)
}).catch(err => console.log(err))
}
}
Video report: https://www.dropbox.com/s/3lzcrtzst0dnomw/Screen%20Recording%202019-10-18%20at%2010.49.43.mov?dl=0
If I use a function without 'async', then the function recursively calls itself and the application crash
Example test code:
onReadAssets = () => {
const url = `${node.asset.url}` // <—— Large file
for (let i = 0; i < 1000; i++) {
RNFS.read(url, 16777216, 0, 'base64').then((data) => { // 16777216 - 16MB chunk, 0 - start seek
console.log('Read file', i)
}).catch(err => console.log(err))
}
}
Video report: https://www.dropbox.com/s/aq3y9dfeqo4mo7o/Screen%20Recording%202019-10-18%20at%2010.52.40.mov?dl=0
I found a similar problem in :
https://github.com/itinance/react-native-fs/issues/746
Thanks.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.