Reactive Extensions memory usage

I have the following code in a WPF application using Reactive Extensions for .NET:

public MainWindow()
{
    InitializeComponent();

    var leftButtonDown = Observable.FromEvent<MouseButtonEventArgs>(this, "MouseLeftButtonDown");
    var leftButtonUp = Observable.FromEvent<MouseButtonEventArgs>(this, "MouseLeftButtonUp");

    var moveEvents = Observable.FromEvent<MouseEventArgs>(this, "MouseMove")
        .SkipUntil(leftButtonDown)
        .SkipUntil(leftButtonUp)
        .Repeat()
        .Select(t => t.EventArgs.GetPosition(this));

    moveEvents.Subscribe(point =>
    {
        textBox1.Text = string.Format(string.Format("X: {0}, Y: {1}", point.X, point.Y));
    });
}

Will there be a constant increase in memory when the mouse moves through this dialog box?

While reading the code, I expect the variable moveEvents to contain a huge amount of MouseEventArgs after some time? Or is it being processed in some smart way that I don’t know about?

+3
source share
1 answer

No, there should not be a constant increase in memory use - why was it? Events are mainly transmitted to the subscriber; they are not buffered anywhere.

Rx - , , , . , .

( Rx, , .)

+5

Source: https://habr.com/ru/post/1750000/


All Articles