Click here to Skip to main content
15,895,656 members
Home / Discussions / C#
   

C#

 
GeneralRe: memory footprint of Dictionary Pin
George_George17-May-08 3:35
George_George17-May-08 3:35 
GeneralRe: memory footprint of Dictionary Pin
Guffa17-May-08 6:29
Guffa17-May-08 6:29 
GeneralRe: memory footprint of Dictionary Pin
George_George17-May-08 21:31
George_George17-May-08 21:31 
GeneralRe: memory footprint of Dictionary Pin
Guffa18-May-08 12:34
Guffa18-May-08 12:34 
GeneralRe: memory footprint of Dictionary Pin
George_George20-May-08 22:40
George_George20-May-08 22:40 
GeneralRe: memory footprint of Dictionary Pin
Guffa20-May-08 23:17
Guffa20-May-08 23:17 
GeneralRe: memory footprint of Dictionary Pin
George_George20-May-08 23:43
George_George20-May-08 23:43 
GeneralRe: memory footprint of Dictionary Pin
Guffa21-May-08 3:28
Guffa21-May-08 3:28 
George_George wrote:
next field is used to keep a linked list for all the items which has the same hash code?


I don't know, really. I haven't examined the internal code of the dictionary that closely.

George_George wrote:
So, each reference type variable will use 8 bytes on 32-bit machine, and 16 bytes on a 64-bit machine?


No. On a 32-bit system a reference is 32 bits, which is 4 bytes.

George_George wrote:
In C#, is it working the same way -- only grow when it is full?


Yes.

George_George wrote:
I am confused about why do you think a Dictionary is always keeping at least 50% unused items


I never said that. Where did you get that from?

George_George wrote:
For example, if in the old Dictionary, the capability is 10 but used item is only 3. If I create a new Dictionary, and insert the 3 elements into the new Dictionary, I am not sure whether the capability of the new Dictionary is still 10.


Then you have 70% unused entries, so the new dictionary is very likely to shrink. If you for example have 4 items in a dictionary with the capacity 7, and copy to a new dictionary, the capacity of the new dictionary would also be 7.

The capacity of a dictionary is always a prime number (for some not so obvious reason). When growing the internal array, it picks the closest higher prime number.

You can download Lutz Roeder's .NET Reflector to look at the code of the dictionary (you find it in the mscorlib dll).

If you want to check the capacity of a dictionary object, you have to use reflection to check the length of the private entries array.

Despite everything, the person most likely to be fooling you next is yourself.

GeneralRe: memory footprint of Dictionary Pin
George_George21-May-08 4:28
George_George21-May-08 4:28 
GeneralRe: memory footprint of Dictionary Pin
Guffa21-May-08 11:17
Guffa21-May-08 11:17 
GeneralRe: memory footprint of Dictionary Pin
George_George25-May-08 1:38
George_George25-May-08 1:38 
GeneralRe: memory footprint of Dictionary Pin
Guffa25-May-08 13:07
Guffa25-May-08 13:07 
GeneralRe: memory footprint of Dictionary Pin
George_George25-May-08 19:14
George_George25-May-08 19:14 
GeneralRe: memory footprint of Dictionary Pin
Guffa25-May-08 22:05
Guffa25-May-08 22:05 
GeneralRe: memory footprint of Dictionary Pin
George_George25-May-08 22:19
George_George25-May-08 22:19 
AnswerRe: memory footprint of Dictionary Pin
PIEBALDconsult17-May-08 5:50
mvePIEBALDconsult17-May-08 5:50 
GeneralRe: memory footprint of Dictionary Pin
George_George17-May-08 21:27
George_George17-May-08 21:27 
GeneralRe: memory footprint of Dictionary Pin
PIEBALDconsult18-May-08 5:01
mvePIEBALDconsult18-May-08 5:01 
GeneralRe: memory footprint of Dictionary Pin
George_George20-May-08 22:08
George_George20-May-08 22:08 
QuestionHow can I ... Pin
maresp198217-May-08 1:03
maresp198217-May-08 1:03 
AnswerRe: How can I ... Pin
Christian Graus17-May-08 1:06
protectorChristian Graus17-May-08 1:06 
GeneralRe: How can I ... Pin
maresp198217-May-08 1:50
maresp198217-May-08 1:50 
GeneralRe: How can I ... [modified] Pin
#realJSOP17-May-08 2:26
mve#realJSOP17-May-08 2:26 
GeneralRe: How can I ... Pin
maresp198217-May-08 3:08
maresp198217-May-08 3:08 
GeneralRe: How can I ... Pin
#realJSOP17-May-08 3:13
mve#realJSOP17-May-08 3:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.