Skip to content

Conversation

@grokys
Copy link
Member

@grokys grokys commented Jun 23, 2018

A large proportion of our memory usage is taken up by Rx operators. The standard rx operators carry out a lot of allocations for two reasons:

  1. To be thread-safe
  2. Because they are general purpose and need to be chained together

This PR introduces a new LightweightObservableBase<T> class which takes advantage of the fact that our UI is single-threaded, and is used to build custom rx classes so that we no longer need to chain standard rx operators.

Memory usage

Memory usage was measured via the VS2017 diagnostic tools by running ControlCatalog in Release mode, opening all pages and then taking a memory snapshot:

master:

Objects Heap Size (KB)
3,416,050 155,117

This PR:

Objects Heap Size (KB)
1,478,158 79,936

@grokys grokys changed the title WIP: Use custom Rx classes Use custom Rx classes Jun 23, 2018
@grokys grokys requested a review from a team June 23, 2018 13:36
@wieslawsoltes
Copy link
Collaborator

LGTM tested with Core2D no issues.

{
if (_observer != null)
{
_observer?.OnNext(value);
Copy link
Contributor

Choose a reason for hiding this comment

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

Check for null call twice?

Copy link
Member Author

Choose a reason for hiding this comment

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

Well spotted, thanks!

@wieslawsoltes wieslawsoltes requested review from wieslawsoltes and removed request for wieslawsoltes June 24, 2018 11:15
@grokys grokys merged commit a9cdfea into master Jun 25, 2018
@grokys grokys deleted the custom-rx branch June 25, 2018 07:40
@grokys grokys added this to the 0.7.0 milestone Apr 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants