E
E
Envywewok2019-05-20 15:10:22
C++ / C#
Envywewok, 2019-05-20 15:10:22

How to determine the memory size of a dictionary in C#?

There is a dictionary

Dictionary<string, int[,]> tails = new Dictionary<string, int[,]>();

Then I fill it with data and how to find out how much it takes up memory space?
And more extra. the question is when I open a dictionary in the debugger for some reason, the data is duplicated, what could be the problem?
Here is a photo, logically I should have only one such pair.
5ce2991165ec8343895298.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
#
#, 2019-05-20
@Envywewok

1 - https://www.jetbrains.com/dotmemory/ since the studio is not nice to you ..
2 - you can roughly estimate by running through the dictionary, and taking the lengths of the strings (do not forget that this is Unicode) and the sizes of the arrays (again, int == int32 usually), and adding the size of the dictionary (assuming the size of the address, based on the platform)... (in fact, the size of the address array of the dictionary is most likely a multiple of some power of two, or rather a set of blocks, the size of which is powers of two.. but this error, most likely, will not be fundamental, it can be easily insured by throwing a kilobyte)
ps somewhere it will help https ://docs.microsoft.com/en-us/dotnet/csharp/lan... ))
pps https://habr.com/ru/post/136609/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question