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

Implement BlobCollector #12269

Merged
merged 3 commits into from
Oct 20, 2023
Merged

Conversation

JunielKatarn
Copy link
Contributor

@JunielKatarn JunielKatarn commented Oct 20, 2023

Description

Allows disposing of unused Blob data when JS garbage collection takes place.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)

Why

Continuous instantiation of Blob JavaScript objects can lead to memory leaks because the disposal of those objects does not trigger the deallocation of the blob data on the native side (see IBlobPersistor).

For further context:

What

  • Define Microsoft::React::BlobCollector.
    • Gets attached to the JavaScript Blob instance lifetime and cleans up its corresponding blob data on destruction.
  • Register factory method __blobCollectorProvider through JSI.

Important: This fix only applies to the TurboModule variant.
We need to figure out a way to set this up for the Blob CxxModule, which requires accessing its facebook::jsi::Runtime instance reference.

Testing

Use proof of concept https://github.com/jurocha-ms/Repro/tree/blobmemleak/ReactNative/fetchwinleak (see README).

Microsoft Reviewers: Open in CodeFlow

@JunielKatarn JunielKatarn merged commit 0b31812 into microsoft:main Oct 20, 2023
43 checks passed
@JunielKatarn JunielKatarn deleted the blob-collector branch October 20, 2023 20:31
JunielKatarn added a commit that referenced this pull request Oct 20, 2023
* Implement BlobCollector

* Change files

* clang format
JunielKatarn added a commit that referenced this pull request Oct 20, 2023
* Implement BlobCollector

* Change files

* clang format
JunielKatarn added a commit that referenced this pull request Oct 20, 2023
* Implement BlobCollector

* Change files

* clang format
JunielKatarn added a commit that referenced this pull request Oct 21, 2023
* Implement BlobCollector (#12269)

* Implement BlobCollector

* Change files

* clang format

* Remove change files

* Change files
JunielKatarn added a commit that referenced this pull request Oct 21, 2023
* Implement BlobCollector (#12269)

* Implement BlobCollector

* Change files

* clang format

* Remove change files

* Change files
JunielKatarn added a commit that referenced this pull request Oct 21, 2023
* Implement BlobCollector (#12269)

* Implement BlobCollector

* Change files

* clang format

* Remove change files

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

Successfully merging this pull request may close these issues.

None yet

2 participants