Skip to content

Conversation

@RLittlesII
Copy link
Member

What kind of change does this PR introduce?

Resolves: #2377

What is the current behavior?

When you run the sample provided in the report after a few updates, Blazor will throw an OutOfMemoryException.

What is the new behavior?

The sample no longer throw the exception.

What might this PR break?

ReactiveComponentBase

Please check if the PR fulfills these requirements

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

Other information:

I tested my changes on a branch of the provided sample. I will note that even though I am now disposing of the subscription with a composite disposable, I stopped seeing the issue as soon as I moved it into the firstRender check.

I let the app run for over an hour and did not experience the issue. The most I did see logged on the memory footprint was a call to the GC that the nursery is full.

GC_MINOR: (Nursery full) time 5.00ms, stw 5.00ms promoted 287K major size: 1152K in use: 409K los size: 1024K in use: 16K

https://github.com/RLittlesII/BlazorReactiveUI/tree/fix/memory-leak

@RLittlesII RLittlesII requested a review from a team April 29, 2020 19:48
@codecov
Copy link

codecov bot commented Apr 29, 2020

Codecov Report

Merging #2400 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #2400   +/-   ##
=======================================
  Coverage   54.69%   54.69%           
=======================================
  Files         114      114           
  Lines        4344     4344           
  Branches      663      663           
=======================================
  Hits         2376     2376           
  Misses       1801     1801           
  Partials      167      167           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b87e6c9...b9b69e7. Read the comment docs.

.Publish()
.RefCount();
this.WhenAnyValue(x => x.ViewModel);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both need Where(x != null). Avoid the Skip below.

Add RefCount(2) and that should avoid the two observables being made.

@glennawatson glennawatson merged commit c6697c5 into master May 1, 2020
@glennawatson glennawatson deleted the feature/reactive-component branch May 1, 2020 18:11
@github-actions
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 24, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Memory leak using ReactiveUI with Blazor Web Assembly

3 participants