Description
Problem Description
Memory reserved for Blob data is not being released after the JS-side owning objects go out of scope causing its usage to keep growing with each allocation.
Specifically, the BlobCollector
' type associated with DefaultBlobResource
never gets its destructor called.
https://github.com/microsoft/react-native-windows/blob/react-native-windows_v0.72.19/vnext/Shared/Modules/BlobCollector.cpp#L17
Root Cause
Hermes does not correctly release resources during garbage collection.
facebook/hermes#1147
A fix in Hermes for Windows has been recently integrated:
microsoft/hermes-windows#169
This issue will be closed once the fix is verified.
Steps To Reproduce
See https://github.com/jurocha-ms/Repro/tree/main/ReactNative/fetchwinleak for a straightforward repro.
- Instantiate any number of Blob objects without holding references to them, i.e. multiple
fetch
calls returning reasonably large (ideally multi-megabyte) content.
Workaround:
Reload the React Native instance.
However, this may trigger #12187.
Expected Results
Memory usage stays constant as Blob objects are discarded.
CLI version
Any (latest main
as of time of posting).
Environment
info Fetching system and libraries information...
System:
OS: Windows 10 10.0.22631
CPU: (16) x64 Intel(R) Xeon(R) Platinum 8370C CPU @ 2.80GHz
Memory: 56.66 GB / 63.95 GB
Binaries:
Node:
version: 18.16.0
path: C:\Program Files\nodejs\node.EXE
Yarn:
version: 1.22.19
path: C:\Program Files (x86)\Yarn\bin\yarn.CMD
npm:
version: 9.5.1
path: C:\Program Files\nodejs\npm.CMD
Watchman: Not Found
SDKs:
Android SDK: Not Found
Windows SDK:
AllowDevelopmentWithoutDevLicense: Enabled
AllowAllTrustedApps: Enabled
Versions:
- 10.0.18362.0
- 10.0.19041.0
- 10.0.22000.0
- 10.0.22621.0
IDEs:
Android Studio: Not Found
Visual Studio:
- 17.8.34309.116 (Visual Studio Enterprise 2022)
Languages:
Java: 11.0.16.1
Ruby: Not Found
npmPackages:
"@react-native-community/cli": Not Found
react: Not Found
react-native: Not Found
react-native-windows: Not Found
npmGlobalPackages:
"*react-native*": Not Found
Android:
hermesEnabled: Not found
newArchEnabled: Not found
iOS:
hermesEnabled: Not found
newArchEnabled: Not found
Target Platform Version
None
Target Device(s)
No response
Visual Studio Version
None
Build Configuration
None
Snack, code example, screenshot, or link to a repository
https://github.com/jurocha-ms/Repro/tree/main/ReactNative/fetchwinleak
Metadata
Metadata
Assignees
Type
Projects
Status