D
D
Denis Goncharenko2016-05-08 20:05:39
C++ / C#
Denis Goncharenko, 2016-05-08 20:05:39

Why is memory jumping?

You need to create a custom element.
I create:

public class MyControl : Control
{
...
}

I render as follows, as in the docks:
protected override void OnPaint(PaintEventArgs e)
{
    base.OnPaint(e);
    ...
}

An animation is drawn in the element itself, an object is drawn through a timer, and the coordinates change in each iteration.
The bottom line is, if you just draw the control once, then everything is fine with the memory, we look in the task manager - it does not change. We resize the form - the used memory grows, it seems to be logical.
But, if you add
this.Invalidate();
That to the cycle, the memory starts growing immediately after the application is launched, then the truth stops at some value, but still.
Even if writing
this.Invalidate(region);
Where region is a required square for redrawing, nothing changes, even if you put region with parameters (0, 0, 1, 1), the memory grows. Moreover, if you just leave it in the Invalidate loop while not rendering anything on the form at all, the memory also grows. There are no memory allocations in the timer loop, I remove them from the timer, everything except Invalidate, the memory still grows immediately without resizing the window.
How to be? Requirements such that storage should not jump.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
M
MrDywar Pichugin, 2016-05-08
@Dywar

Visual Studio 2015, during startup, a window will appear on the right in which you can take snapshots of memory, and comparing them to find those objects of which there are more. Find out who creates them and why.

D
Denis Goncharenko, 2016-05-08
@denis79513

And now I'm generally at an impasse, the visual says what it says, but in the task manager during this time the pvmyat grows by 2.5 meters.
36fb220bf77f48cc91addc38b294c346.jpg

A
AxisPod, 2016-05-10
@AxisPod

Why draw in WPF like in Windows Forms?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question