V
V
Vitaly Yakovenko2013-03-26 01:18:25
go
Vitaly Yakovenko, 2013-03-26 01:18:25

How to check if garbage collection works well?

Now the application starts with a memory consumption of 1.5 Mb, when checking (manually connecting from the client, trying to generate the maximum load) it gradually grows to 8-9 Mb and stops at this mark (even if I continue to create chaos with the client).
There is one more thing, in theory, the application should free up memory (by unloading unused parts), but over time, consumption does not decrease (judging by the task manager).
So the question is: how to make sure that the memory does not run away, and if everything is fine, then why does the consumption stop at 8 MB instead of decreasing to the initial level?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
J
jj_killer, 2013-03-26
@Xazzzi

It should not release unless the system asks. This is how most assemblers work, they give memory "back to the program".

I
Iliapan, 2013-03-26
@Iliapan

freeing memory is an extremely resource-intensive process. therefore, it is produced by the garbage collector only at the urgent request of the system itself, well, or regularly, when there is no other load at all

S
Sergey Kharchenko, 2013-03-26
@lenferer

What OS and what language are you using?

A
afiskon, 2013-03-26
@afiskon

The garbage collector may not physically release the memory if it once needed 8 MB to work. There is a chance that this volume will be needed again, in which case the program will run faster if the objects have already been created. There is also such a thing as memory fragmentation. Part of the memory may not be used at all and be reserved for compacting objects, for example, it depends on the type of GC. Some details here for example.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question