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

Memory leaks with `backgroundUpload` causing crashes

Open GunnarAK opened this issue 1 year ago • 3 comments

Current behavior

Uploading 69 video files ranging from 12 MB to 170 MB (using an asyncqueue with concurrency limit of 5) will cause to increase the memory usage on iOS Simulator easily to 4 GB without releasing memory after a successful upload. Unmounting the uploading logic in JS will also not release memory.

I have received various crash reports from Firebase Crashlytics about iPhones experiencing crashes due to this.

Expected behavior

After an upload is done the memory should be released from that task.

Platform

  • [ ] Android
  • [X] iOS

With an Simulator running iOS 16.4 I'm able to reproduce this 100% of the time. Simulator running iOS 17.4 does not report this issue with the Performance Monitor On real devices it appears to happen on iOS 18 as well. And don't recall with certainty, but also iOS 17 on real devices.

React Native Version

0.73.2

React Native Compressor Version

1.8.24

Reproducible Steps And Demo

  1. Have a large set of video files (any multitude of the concurrency limit)
  2. Optional: Write async queue logic with concurrency limit of 5
  3. Upload multiple files to a (local) server
  4. Check RAM usage before and after uploading

Video demo

https://mega.nz/file/J4kDTJbT#Tf_zWMLtmg98Ax921nRlCkxh2YnouabflKnk0G-PgUE

GunnarAK avatar Apr 30 '24 10:04 GunnarAK

I've also tried 'cancelling' an upload after its done, hoping it would collect the garbage. But unfortunately it does nothing.

GunnarAK avatar Apr 30 '24 10:04 GunnarAK

@numandev1 hey man, hope you're doing well!

Are you able to reproduce this?

GunnarAK avatar May 14 '24 16:05 GunnarAK

This issue is stale because it has been open 365 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] avatar Jun 22 '25 03:06 github-actions[bot]

This issue was closed because it has been stalled for 7 days with no activity.

github-actions[bot] avatar Jun 29 '25 03:06 github-actions[bot]