Skip to content

Memory leaks caused by shareReplay when shared observable is synchronous or continuous #5931

@MaximSagan

Description

@MaximSagan

Bug Report

Current Behavior
Under certain common conditions, use of the shareReplay operator will cause memory leaks. This is similar to what was documented in #5034, but although that issue was marked as resolved by #5044, it can be observed in the linked example that the problem persists to a considerable degree.

Reproduction
https://stackblitz.com/edit/angular-a27w1c
https://angular-a27w1c.stackblitz.io/

  1. Open up https://angular-a27w1c.stackblitz.io/ in Chrome
  2. Use the checkboxes to create and destroy each of the components.
  3. Once they are all destroyed, use the devtools Memory tab to take a heap snapshot, and search for the word "Component".
  4. Observe that while the AsyncSingleComponent was indeed destroyed, the SyncComponent and the AsyncContinuousComponent have stuck around.

Expected behavior
Each of the three components should have their class instances garbage-collected.

Environment

  • See Stackblitz above
  • RxJS version: 6.6.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions