I have the following nested dictionaries:
Dictionary<int, Dictionary<string, object>> x;
Dictionary<int, SortedDictionary<long, Dictionary<string, object>>> y;
If I execute x.Clear()and y.Clear(), will all nested objects be cleared and all memory will be reused in the next garbage collection?
x.Clear()
y.Clear()
Or do I need to iterate over all the elements and clean them manually?
If none of your objects are accessible from other parts of your code, all of them will collect garbage.
If this is done in the next garbage collection, it depends on the generation to which they belong.
.
: GC ( ) . , , .
, - , .
Maybe yes.
If you have links to elements in the dictionary, regardless of the type of the value parameter, then these objects will not be collected.
But if there are no links, then they will be assembled (at some point).
Source: https://habr.com/ru/post/1739297/More articles:Where can I find ASP.NET MVC2 documentation / tutorials? - asp.netHow to run jQuery form validation by class? - jqueryWhy can't I bind the viewmodel property to the dependency property of a custom control - c #change vertex color in vertex shader - openglCreating a simple array - arraysregex: how to eliminate URLs ending in .dtd - regexCommon mistake in GDI + - permissions - iisComparison of differences in workspace entrie in TFS - tfsКасательная часть параметрической дискретной кривой - c++WPF RichTextBox - selected block? - c #All Articles