clearing memory from dictionary

  • Thread starter Thread starter buu
  • Start date Start date
B

buu

It's strange to me, but, create a dictionary and fill it with 1 mil. of some
objects.
then, see the memory consumption (arised, of course).

then, clean the dictionary.... memory consumption is the same...
write MyDic=nothing

memory consumption is still the same
force GC to collect... memory consumption is little bit smaller

why?
how can I release memory prevously kept by dictionary?
 
buu said:
It's strange to me, but, create a dictionary and fill it with 1 mil. of some
objects.
then, see the memory consumption (arised, of course).

then, clean the dictionary.... memory consumption is the same...
write MyDic=nothing

memory consumption is still the same
force GC to collect... memory consumption is little bit smaller

Forcing a garbage collection rarely has any dramatic effect. If a
garbage collection is needed, it will be done automatically.
why?
how can I release memory prevously kept by dictionary?

The memory will be released if it's needed for something else.

What you are seeing is not the amount of memory that is used for active
objects, you see the amount of memory that is currently allocated for
the memory heaps in the .NET memory management system. If you want to
see how much memory is really used, you should use a memory profiler.
 
Back
Top