Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUGS:] Memory leak and application crash on reading a large file #785

Open
nikolaytsigvintsev opened this issue Oct 18, 2019 · 3 comments

Comments

@nikolaytsigvintsev
Copy link

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 :
#746

Thanks.

@sarevok89
Copy link

I'm currently struggling with the same issue. Using the RNFS.read() method in a loop doesn't release the memory for some reason. There's a linear growth in memory usage with each read/uploaded file chunk.

@H4mxa
Copy link

H4mxa commented Oct 2, 2023

any update on this issue.

@7adidaz
Copy link

7adidaz commented Mar 31, 2024

this is still unresolved, unfortunately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants