Skip to content

fetch() leaks memory on each request due to unreleased Blobs #19248

Description

@jesenko

Environment

Environment:
OS: macOS Sierra 10.12.6
Node: 8.9.4
Yarn: 1.6.0
npm: 5.6.0
Watchman: 4.7.0
Xcode: Xcode 8.3.3 Build version 8E3004b
Android Studio: 3.1 AI-173.4720617

Packages: (wanted => installed)
react: 16.3.1 => 16.3.2
react-native: ~0.55.2 => 0.55.4

Steps to Reproduce

Execute request using fetch, e.g.

fetch('https://www.facebook.com').then(res => {
   // fetch saves response to blob: res._bodyBlob._data
});

Expected Behavior

Blob with fetch response should be released once res is out of scope (GC-ed).

Actual Behavior

Blobs corresponding to fetch response are never released, leading to increasing memory usage during a lifetime of application. Leaked memory is at least of the size of all responses already received.

I have created a simple project, demonstrating memory leak: https://github.com/jesenko/react-native-fetch-memory-leak

Issue was probably introduced with #11573, and is thus affecting v0.54 and v0.55

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Impact: RegressionDescribes a behavior that used to work on a prior release, but stopped working recently.Issue: Author Provided ReproThis issue can be reproduced in Snack or an attached project.JavaScriptResolution: LockedThis issue was locked by the bot.🌐NetworkingRelated to a networking API.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions