D
D
Denis Goncharenko2016-05-09 07:33:13
.NET
Denis Goncharenko, 2016-05-09 07:33:13

How to tame a GC that reserves memory "in reserve"?

Windows forms project. After calling the Invalidate() method, the application's memory grows, the GC reserves it for possible needs. In fact, the memory actually used by the application remains unchanged. But I know that no more objects will be created in the program, they will only be redrawn, how can I get rid of the reserved memory "in reserve"? I understand that this is not really important, because. if the system runs out of memory, then the GC releases the excess, but nevertheless, I need the application not to eat extra memory, or eat it, but this memory did not increase over time (with each call to Invalidate).

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stanislav Makarov, 2016-05-09
@Nipheris

In fact, the memory actually used by the application remains unchanged.

Where does such a conclusion come from?
An even more absurd statement. Who says redrawing doesn't create objects? What about Graphics objects?
I could be wrong, but I've never heard of reserve memory. Apparently, objects are still being created.
She will meet from time to time, as you said. The less free memory in the system, the more often garbage collection will occur. If these conditions are not strong enough for you, use languages ​​with manual memory management.
Also check that you don't leak IDisposable objects. You can call GC.Collect, but that in itself is a temporary solution.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question